23 #ifndef O2SCL_ERR_HND_H
24 #define O2SCL_ERR_HND_H
36 #ifndef DOXYGEN_NO_O2NS
155 static void gsl_hnd(
const char *reason,
const char *file,
156 int line,
int lerrno) {
161 virtual void set(
const char *reason,
const char *file,
162 int line,
int lerrno)=0;
165 virtual void get(
const char *&reason,
const char *&file,
166 int &line,
int &lerrno)=0;
178 virtual const char *
get_file()
const=0;
181 virtual const char *
get_str()=0;
184 virtual void reset()=0;
187 virtual const char *
type()
const=0;
208 virtual void set(
const char *reason,
const char *file,
209 int line,
int lerrno);
212 virtual void get(
const char *&reason,
const char *&file,
213 int &line,
int &lerrno);
225 virtual const char *
get_file()
const;
231 virtual void reset();
237 virtual const char *
type()
const {
return "err_hnd_gsl"; }
241 #ifndef DOXYGEN_INTERNAL
273 #define O2SCL_ERR(d,n) o2scl::set_err_fn(d,__FILE__,__LINE__,n);
277 #define O2SCL_CONV(d,n,b) {if (b) o2scl::set_err_fn(d,__FILE__,__LINE__,n);}
281 #define O2SCL_ERR2(d,d2,n) o2scl::set_err_fn((std::string(d)+d2).c_str(), \
282 __FILE__,__LINE__,n);
286 #define O2SCL_CONV2(d,d2,n,b) {if (b) \
287 o2scl::set_err_fn((std::string(d)+d2).c_str(), \
288 __FILE__,__LINE__,n);}
292 #define O2SCL_CONV_RET(d,n,b) \
293 do { if (!b) { return n; } else { \
294 o2scl::set_err_fn(d,__FILE__,__LINE__,n); return n; } } while (0)
298 #define O2SCL_CONV2_RET(d,d2,n,b) \
299 do { if (!b) { return n; } else { \
300 o2scl::set_err_fn((std::string(d)+d2).c_str(), \
301 __FILE__,__LINE__,n); return n; } } while (0)
307 inline void set_err_fn(
const char *desc,
const char *file,
int line,
321 #ifdef O2SCL_NEVER_DEFINED
328 #define O2SCL_ASSERT(ev) \
329 do { if (ev!=0) { std::cout << "O2scl: Macro err_assert() causing exit" \
330 << " from error " << ev << " at " \
331 << __LINE__ << " in file:\n " \
332 << __FILE__ << std::endl; \
333 std::cout << "Error handler string:\n " << err_hnd->get_str() \
334 << std::endl; exit(ev); } } while (0)
339 #define O2SCL_BOOL_ASSERT(ev,str) \
340 do { if (ev==false) { \
341 std::cout << "O2scl: Macro bool_assert() causing exit at line " \
342 << __LINE__ << " in file:\n " \
343 << __FILE__ << std::endl; \
344 std::cout << "Given string: " << str \
345 << std::endl; exit(-1); } } while (0)
349 #ifndef DOXYGEN_NO_O2NS
static void gsl_hnd(const char *reason, const char *file, int line, int lerrno)
Set an error.
iterative process is out of control
virtual const char * type() const =0
Return type.
Class defining an error handler [abstract base].
err_hnd_gsl alt_err_hnd
An alternate GSL-like error handler.
err_hnd_type * err_hnd
The global error handler pointer.
static const int rsize
The maximum size of error explanations.
void set_err_fn(const char *desc, const char *file, int line, int errnum)
Call the error handler.
sanity check failed - shouldn't happen
invalid argument supplied by user
virtual const char * get_reason() const
Return the reason for the last error.
requested feature is not supported by the hardware
apparent singularity detected
exceeded max number of iterations
failed to reach the specified tolerance
virtual int get_line() const =0
Return the line number of the last error.
table table limit exceeded
iteration has not converged
void error_update(int &ret, int err)
Update an error value err with the value in ret.
Generic "not found" result.
requested feature not (yet) implemented
iteration is not making progress toward solution
matrix, vector lengths are not conformant
virtual const char * get_str()=0
Return a string summarizing the last error.
virtual const char * get_file() const
Return the file name of the last error.
char * a_file
The filename.
jacobian jacobian evaluations are not improving the solution
input domain error, e.g sqrt(-1)
virtual const char * get_reason() const =0
Return the reason for the last error.
virtual const char * type() const
Return type ("err_hnd_gsl")
char a_reason[rsize]
The error explanation.
char fullstr[fsize]
A full string with explanation and line and file info.
virtual const char * get_str()
Return a string summarizing the last error.
int a_errno
The error number.
std::string errno_to_string(int errnox)
Convert an error number to a string.
virtual void reset()=0
Remove last error information.
cannot reach the specified tolerance in x
cannot reach the specified tolerance in gradient gradient
output range error, e.g. exp(1e100)
Outside constraint region.
virtual int get_line() const
Return the line number of the last error.
int a_line
The line number.
virtual int get_errno() const
Return the last error number.
problem with user-supplied function
virtual void set(const char *reason, const char *file, int line, int lerrno)=0
Set an error.
static const int fsize
The maximum size of error explanations with the line and file info.
Incorrect type for memory object.
virtual int get_errno() const =0
Return the last error number.
size_t fname_size
Number of characters from filename to print (default 28)
Invalid index for array or matrix.
virtual void reset()
Remove last error information.
virtual const char * get_file() const =0
Return the file name of the last error.
virtual void set(const char *reason, const char *file, int line, int lerrno)
Set an error.
user specified an invalid tolerance
failed because of roundoff error
integral or series is divergent
cannot reach the specified tolerance in f