libtime++: Date and time calculation
error.cc
Go to the documentation of this file.
1 
34 #define TF_ERROR_CC_VERSION \
35  "TF_ERROR_CC V1.0 "
36 
37 #include <iostream>
38 #include <libtime++.h>
39 
40 using std::cerr;
41 using std::endl;
42 
43 namespace libtime {
44 
47 
50  Mmessage(0), Mfile(0), Mline(0), Mcondition(0)
51  { if (Mreport_on_construct) { report(); } }
52 
54  Exception::Exception(const char* message):
55  Mmessage(message), Mfile(0), Mline(0), Mcondition(0)
56  { if (Mreport_on_construct) { report(); } }
57 
59  Exception::Exception(const char* message,
60  const char* condition):
61  Mmessage(message), Mfile(0), Mline(0), Mcondition(condition)
62  { if (Mreport_on_construct) { report(); } }
63 
65  Exception::Exception(const char* message,
66  const char* file,
67  const int& line):
68  Mmessage(message), Mfile(file), Mline(line), Mcondition(0)
69  { if (Mreport_on_construct) { report(); } }
70 
72  Exception::Exception(const char* message,
73  const char* file,
74  const int& line,
75  const char* condition):
76  Mmessage(message), Mfile(file), Mline(line), Mcondition(condition)
77  { if (Mreport_on_construct) { report(); } }
78 
81  {
83  }
84 
87  {
89  }
90 
92  void Exception::report() const
93  {
94  base_report();
95  }
96 
99  {
100  cerr << "Exception report:" << endl;
101  if (Mmessage==0)
102  {
103  cerr << " No message" << endl;
104  }
105  else
106  {
107  cerr << " message: " << Mmessage << endl;
108  }
109  if (Mfile!=0)
110  {
111  cerr << " triggered in \"" << Mfile << "\" at line #" << Mline << endl;
112  }
113  if (Mcondition!=0)
114  {
115  cerr << " by condition:" << endl
116  << " \"" << Mcondition << "\"" << endl;
117  }
118  }
119 
120 } // namespace libtime
121 
122 /* ----- END OF error.cc ----- */
Exception()
Creates exception with no explaining comments.
Definition: error.cc:49
const char * Mcondition
pointer to assertion condition text string
Definition: libtime++.h:690
const char * Mmessage
pointer to message string
Definition: libtime++.h:684
static void report_on_construct()
Issue a screen report on construction of exception.
Definition: error.cc:80
const char * Mfile
pointer to file name string
Definition: libtime++.h:686
const int & Mline
pointer to line number in source file
Definition: libtime++.h:688
static void dont_report_on_construct()
Issue NO screen report on construction of exception.
Definition: error.cc:86
static bool Mreport_on_construct
Shall we print to cerr at construction time?
Definition: libtime++.h:682
void base_report() const
Screen report.
Definition: error.cc:98
virtual void report() const
Screen report.
Definition: error.cc:92