Go to the documentation of this file.
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_ERR3(d,d2,d3,n) o2scl::set_err_fn(\
287 (std::string(d)+d2+d3).c_str(),__FILE__,__LINE__,n);
291 #define O2SCL_CONV2(d,d2,n,b) {if (b) \
292 o2scl::set_err_fn((std::string(d)+d2).c_str(), \
293 __FILE__,__LINE__,n);}
297 #define O2SCL_CONV_RET(d,n,b) \
298 do { if (!b) { return n; } else { \
299 o2scl::set_err_fn(d,__FILE__,__LINE__,n); return n; } } while (0)
303 #define O2SCL_CONV2_RET(d,d2,n,b) \
304 do { if (!b) { return n; } else { \
305 o2scl::set_err_fn((std::string(d)+d2).c_str(), \
306 __FILE__,__LINE__,n); return n; } } while (0)
312 inline void set_err_fn(
const char *desc,
const char *file,
int line,
329 #ifdef O2SCL_NEVER_DEFINED
336 #define O2SCL_ASSERT(ev) \
337 do { if (ev!=0) { std::cout << "O2scl: Macro err_assert() causing exit" \
338 << " from error " << ev << " at " \
339 << __LINE__ << " in file:\n " \
340 << __FILE__ << std::endl; \
341 std::cout << "Error handler string:\n " << err_hnd->get_str() \
342 << std::endl; exit(ev); } } while (0)
347 #define O2SCL_BOOL_ASSERT(ev,str) \
348 do { if (ev==false) { \
349 std::cout << "O2scl: Macro bool_assert() causing exit at line " \
350 << __LINE__ << " in file:\n " \
351 << __FILE__ << std::endl; \
352 std::cout << "Given string: " << str \
353 << std::endl; exit(-1); } } while (0)
357 #ifndef DOXYGEN_NO_O2NS
@ exc_esing
apparent singularity detected
virtual const char * get_file() const
Return the file name of the last error.
@ exc_erange
output range error, e.g. exp(1e100)
std::string errno_to_string(int errnox)
Convert an error number to a string.
virtual int get_line() const
Return the line number of the last error.
@ exc_efailed
generic failure
@ exc_ezerodiv
tried to divide by zero
The main O<span style='position: relative; top: 0.3em; font-size: 0.8em'>2</span>scl O$_2$scl names...
@ exc_etolf
cannot reach the specified tolerance in f
@ exc_enotfound
Generic "not found" result.
@ exc_emaxiter
exceeded max number of iterations
@ exc_etable
table table limit exceeded
char fullstr[fsize]
A full string with explanation and line and file info.
@ exc_eunimpl
requested feature not (yet) implemented
char a_reason[rsize]
The error explanation.
@ exc_eunsup
requested feature is not supported by the hardware
static void gsl_hnd(const char *reason, const char *file, int line, int lerrno)
Set an error.
virtual void reset()
Remove last error information.
@ exc_edom
input domain error, e.g sqrt(-1)
void error_update(int &ret, int err)
Update an error value err with the value in ret.
@ exc_eloss
loss of accuracy
@ exc_enomem
malloc failed
static const int rsize
The maximum size of error explanations.
virtual const char * get_str()
Return a string summarizing the last error.
@ exc_einval
invalid argument supplied by user
Class defining an error handler [abstract base].
char * a_file
The filename.
void set_err_fn(const char *desc, const char *file, int line, int errnum)
Call the error handler.
static const int fsize
The maximum size of error explanations with the line and file info.
virtual int get_line() const =0
Return the line number of the last error.
@ gsl_continue
iteration has not converged
@ exc_etolg
cannot reach the specified tolerance in gradient gradient
@ exc_enoprog
iteration is not making progress toward solution
virtual const char * get_str()=0
Return a string summarizing the last error.
virtual int get_errno() const
Return the last error number.
virtual void set(const char *reason, const char *file, int line, int lerrno)
Set an error.
@ exc_outsidecons
Outside constraint region.
size_t fname_size
Number of characters from filename to print (default 28)
@ exc_efilenotfound
File not found.
@ exc_etolx
cannot reach the specified tolerance in x
@ exc_ebadlen
matrix, vector lengths are not conformant
int a_errno
The error number.
@ exc_enoprogj
jacobian jacobian evaluations are not improving the solution
virtual const char * get_reason() const
Return the reason for the last error.
@ exc_eindex
Invalid index for array or matrix.
int a_line
The line number.
@ exc_efault
invalid pointer
@ exc_eround
failed because of roundoff error
virtual const char * get_reason() const =0
Return the reason for the last error.
@ exc_esanity
sanity check failed - shouldn't happen
@ exc_ediverge
integral or series is divergent
virtual const char * type() const
Return type ("err_hnd_gsl")
virtual void get(const char *&reason, const char *&file, int &line, int &lerrno)
Get the last error.
virtual const char * get_file() const =0
Return the file name of the last error.
@ exc_etol
failed to reach the specified tolerance
@ exc_erunaway
iterative process is out of control
err_hnd_gsl alt_err_hnd
An alternate GSL-like error handler.
@ exc_efactor
factorization failed
virtual void set(const char *reason, const char *file, int line, int lerrno)=0
Set an error.
virtual int get_errno() const =0
Return the last error number.
@ exc_ememtype
Incorrect type for memory object.
virtual const char * type() const =0
Return type.
err_hnd_type * err_hnd
The global error handler pointer.
virtual void get(const char *&reason, const char *&file, int &line, int &lerrno)=0
Get the last error.
virtual void reset()=0
Remove last error information.
@ exc_ebadtol
user specified an invalid tolerance
@ exc_enotsqr
matrix not square
@ exc_ecache
cache limit exceeded
@ exc_ebadfunc
problem with user-supplied function
Documentation generated with Doxygen. Provided under the
GNU Free Documentation License (see License Information).