DATRW++ library: seismic data I/O with multiple formats
exception.cc
Go to the documentation of this file.
1 /*! \file exception.cc
2  * \brief libdatrwxx exception class (implementation)
3  *
4  * ----------------------------------------------------------------------------
5  *
6  * \author Thomas Forbriger
7  * \date 07/07/2016
8  *
9  * libdatrwxx exception class (implementation)
10  *
11  * Copyright (c) 2016 by Thomas Forbriger (BFO Schiltach)
12  *
13  * ----
14  * This program is free software; you can redistribute it and/or modify
15  * it under the terms of the GNU General Public License as published by
16  * the Free Software Foundation; either version 2 of the License, or
17  * (at your option) any later version.
18  *
19  * This program is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22  * GNU General Public License for more details.
23  *
24  * You should have received a copy of the GNU General Public License
25  * along with this program. If not, see <http://www.gnu.org/licenses/>.
26 
27  * ----
28  *
29  * REVISIONS and CHANGES
30  * - 07/07/2016 V1.0 Thomas Forbriger
31  * - 17/05/2017 V1.1 bug fix: string members must be initialized with
32  * character sequence
33  *
34  * ============================================================================
35  */
36 #define DATRW_EXCEPTION_CC_VERSION \
37  "DATRW_EXCEPTION_CC V1.1"
38 
39 #include <iostream>
40 #include <datrwxx/exception.h>
41 #include <datrwxx/aalibdatrwxx.h>
42 #include <datrwxx/util.h>
43 
44 using std::cerr;
45 using std::endl;
46 
47 namespace datrw {
48 
49  //! initialize and instantiate
51 
52  //! construct from nothing
54  Mmessage(""), Mfile(""), Mline(0), Mcondition("")
55  { if (Mreport_on_construct) { report(); } }
56 
57  //! construct with message
58  Exception::Exception(const std::string& message):
59  Mmessage(message), Mfile(""), Mline(0), Mcondition("")
60  { if (Mreport_on_construct) { report(); } }
61 
62  //! construct with message and file info
63  Exception::Exception(const std::string& message,
64  const std::string& condition):
65  Mmessage(message), Mfile(""), Mline(0), Mcondition(condition)
66  { if (Mreport_on_construct) { report(); } }
67 
68  //! construct with message and file info
69  Exception::Exception(const std::string& message,
70  const std::string& file,
71  const int& line):
72  Mmessage(message), Mfile(file), Mline(line), Mcondition("")
73  { if (Mreport_on_construct) { report(); } }
74 
75  //! construct with message and file info and condition
76  Exception::Exception(const std::string& message,
77  const std::string& file,
78  const int& line,
79  const std::string& condition):
80  Mmessage(message), Mfile(file), Mline(line), Mcondition(condition)
81  { if (Mreport_on_construct) { report(); } }
82 
83  //! switch on
85  {
87  }
88 
89  //! switch off
91  {
93  }
94 
95  //! report
96  void Exception::report() const
97  {
98  base_report();
99  }
100 
101  //! report
103  {
105  Mmessage,
106  Mfile,
107  Mline,
108  Mcondition);
109  }
110 
111 } // namespace datrw
112 
113 /* ----- END OF exception.cc ----- */
a fatal error; processing wil abort as a consequence
Definition: report.h:58
static void dont_report_on_construct()
Issue NO screen report on construction of exception.
Definition: exception.cc:90
static bool Mreport_on_construct
Shall we print to cerr at construction time?
Definition: exception.h:99
const int & Mline
pointer to line number in source file
Definition: exception.h:105
libdatrwxx version string (prototypes)
libdatrwxx exception class (prototypes)
Exception()
Creates exception with no explaning comments.
Definition: exception.cc:53
std::string Mmessage
pointer to message string
Definition: exception.h:101
Root namespace of library.
Definition: aalibdatrwxx.cc:16
utilities used by more than one type of data reader (prototypes)
static void report_on_construct()
Issue a screen report on construction of exception.
Definition: exception.cc:84
void report_violation(const Ereport &t, const std::string &message, const std::string &file, const int &line, const std::string &condition)
report violation of assertion
Definition: report.cc:52
std::string Mfile
pointer to file name string
Definition: exception.h:103
void base_report() const
Screen report.
Definition: exception.cc:102
std::string Mcondition
pointer to assertion condition text string
Definition: exception.h:107
virtual void report() const
Screen report.
Definition: exception.cc:96