LINEAR++ library: AFF to LAPACK
error.cc
Go to the documentation of this file.
1 
34 #define LINEAR_ERROR_CC_VERSION \
35  "LINEAR_ERROR_CC V1.0 "
36 
37 #include <iostream>
38 #include <linearxx/error.h>
39 
40 using std::cerr;
41 using std::endl;
42 
43 namespace linear {
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  /*======================================================================*/
121  // LapackException code
122 
124  LapackException::LapackException(const char* message,
125  const char* subroutine,
126  const char* file,
127  const int& line,
128  const char* condition,
129  const int& value):
130  Exception("ERROR: return value of LAPACK subroutine!",
131  file,line,condition), Mvalue(value), Msubroutine(subroutine),
132  Mmeaning(message) { }
133 
136  {
137  base_report();
138  std::cerr << " The LAPACK subroutine \"" << Msubroutine
139  << "\" returned " << Mvalue << "." << std::endl;
140  std::cerr << " This means:" << std::endl;
141  std::cerr << " " << Mmeaning << std::endl;
142  }
143 
144 
145 } // namespace linear
146 
147 /* ----- END OF error.cc ----- */
static bool Mreport_on_construct
Shall we print to cerr at construction time?
Definition: error.h:96
const char * Mmessage
pointer to message string
Definition: error.h:98
const char * Mmeaning
Definition: error.h:137
virtual void report() const
Screen report.
Definition: error.cc:135
void base_report() const
Screen report.
Definition: error.cc:98
Exception class for this library (prototypes)
const int & Mline
pointer to line number in source file
Definition: error.h:102
static void report_on_construct()
Issue a screen report on construction of exception.
Definition: error.cc:80
Exception()
Creates exception with no explaning comments.
Definition: error.cc:49
static void dont_report_on_construct()
Issue NO screen report on construction of exception.
Definition: error.cc:86
int Mvalue
members to remember
Definition: error.h:135
const char * Mcondition
pointer to assertion condition text string
Definition: error.h:104
const char * Mfile
pointer to file name string
Definition: error.h:100
virtual void report() const
Screen report.
Definition: error.cc:92
LapackException(const char *message, const char *subroutine, const char *file, const int &line, const char *condition, const int &value)
take number of requested elements and their size
Definition: error.cc:124
const char * Msubroutine
Definition: error.h:136
Modules of liblinearxx.a.
Definition: error.cc:43
Base class for exceptions.
Definition: error.h:64