TS++ library: time series library
error.cc
Go to the documentation of this file.
1 
33 #define TSXX_ERROR_CC_VERSION \
34  "TSXX_ERROR_CC V1.0"
35 
36 #include <iostream>
37 #include <tsxx/error.h>
38 
39 using std::cerr;
40 using std::endl;
41 
42 namespace ts {
43 
44 namespace error {
45 
48 
51  Mmessage(NULL), Mfile(NULL), Mline(0), Mcondition(NULL)
52  { if (Mreport_on_construct) { report(); } }
53 
55  Exception::Exception(const char* message):
56  Mmessage(message), Mfile(NULL), Mline(0), Mcondition(NULL)
57  { if (Mreport_on_construct) { report(); } }
58 
60  Exception::Exception(const char* message,
61  const char* condition):
62  Mmessage(message), Mfile(NULL), 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(NULL)
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==NULL)
103  {
104  cerr << " No message" << endl;
105  }
106  else
107  {
108  cerr << " message: " << Mmessage << endl;
109  }
110  if (Mfile!=NULL)
111  {
112  cerr << " triggered in \"" << Mfile << "\" at line #" << Mline << endl;
113  }
114  if (Mcondition!=NULL)
115  {
116  cerr << " by condition:" << endl
117  << " \"" << Mcondition << "\"" << endl;
118  }
119  }
120 
121 } // namespace error
122 
123 } // namespace ts
124 
125 /* ----- END OF error.cc ----- */
const char * Mmessage
pointer to message string
Definition: error.h:93
const char * Mfile
pointer to file name string
Definition: error.h:95
Exception()
Creates exception with no explaning comments.
Definition: error.cc:50
static void report_on_construct()
Issue a screen report on construction of exception.
Definition: error.cc:81
static bool Mreport_on_construct
Shall we print to cerr at construction time?
Definition: error.h:91
void base_report() const
Screen report.
Definition: error.cc:99
static void dont_report_on_construct()
Issue NO screen report on construction of exception.
Definition: error.cc:87
error handling for libtsxx (prototypes)
All stuff in this library will be placed within namespace ts.
Definition: anyfilter.cc:43
const char * Mcondition
pointer to assertion condition text string
Definition: error.h:99
virtual void report() const
Screen report.
Definition: error.cc:93
const int & Mline
pointer to line number in source file
Definition: error.h:97