STFINV library: seek source wavelet correction filter
error.cc
Go to the documentation of this file.
1 
35 #define STFINV_ERROR_CC_VERSION \
36  "STFINV_ERROR_CC V1.0"
37 
38 #include <iostream>
39 #include <stfinv/error.h>
40 
41 using std::cerr;
42 using std::endl;
43 
44 namespace stfinv {
45 
48 
51  Mmessage(0), Mfile(0), Mline(0), Mcondition(0)
52  { if (Mreport_on_construct) { report(); } }
53 
55  Exception::Exception(const char* message):
56  Mmessage(message), Mfile(0), Mline(0), Mcondition(0)
57  { if (Mreport_on_construct) { report(); } }
58 
60  Exception::Exception(const char* message,
61  const char* condition):
62  Mmessage(message), Mfile(0), Mline(0), Mcondition(condition)
63  { if (Mreport_on_construct) { report(); } }
64 
66  Exception::Exception(const char* message,
67  const char* file,
68  const int& line):
69  Mmessage(message), Mfile(file), Mline(line), Mcondition(0)
70  { if (Mreport_on_construct) { report(); } }
71 
73  Exception::Exception(const char* message,
74  const char* file,
75  const int& line,
76  const char* condition):
77  Mmessage(message), Mfile(file), Mline(line), Mcondition(condition)
78  { if (Mreport_on_construct) { report(); } }
79 
82  {
84  }
85 
88  {
90  }
91 
93  void Exception::report() const
94  {
95  base_report();
96  }
97 
100  {
101  cerr << "Exception report:" << endl;
102  if (Mmessage==0)
103  {
104  cerr << " No message" << endl;
105  }
106  else
107  {
108  cerr << " message: " << Mmessage << endl;
109  }
110  if (Mfile!=0)
111  {
112  cerr << " triggered in \"" << Mfile << "\" at line #" << Mline << endl;
113  }
114  if (Mcondition!=0)
115  {
116  cerr << " by condition:" << endl
117  << " \"" << Mcondition << "\"" << endl;
118  }
119  }
120 
121  /*----------------------------------------------------------------------*/
122 
124  void report_violation(const char* message,
125  const char* file,
126  const int& line,
127  const char* condition)
128  {
129  std::cerr << std::endl;
130  std::cerr << "VIOLATION of condition: " << condition << std::endl;
131  std::cerr << "* in " << file << " at line " << line << std::endl;
132  std::cerr << "* message: " << message << std::endl;
133  }
134 
135 } // namespace stfinv
136 
137 /* ----- END OF error.cc ----- */
static bool Mreport_on_construct
Shall we print to cerr at construction time?
Definition: error.h:93
Root namespace of library.
Definition: doxygen.txt:43
Exception()
Creates exception with no explaning comments.
Definition: error.cc:50
handle error conditions in libstfinv (prototypes)
static void report_on_construct()
Issue a screen report on construction of exception.
Definition: error.cc:81
void base_report() const
Screen report.
Definition: error.cc:99
void report_violation(const char *message, const char *file, const int &line, const char *condition)
report violation of assertion
Definition: error.cc:124
virtual void report() const
Screen report.
Definition: error.cc:93
const int & Mline
pointer to line number in source file
Definition: error.h:99
static void dont_report_on_construct()
Issue NO screen report on construction of exception.
Definition: error.cc:87
const char * Mmessage
pointer to message string
Definition: error.h:95
const char * Mcondition
pointer to assertion condition text string
Definition: error.h:101
const char * Mfile
pointer to file name string
Definition: error.h:97