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) {
157 err_hnd->
set(reason,file,line,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 244 std::string errno_to_string(
int errnox);
247 static const int rsize=300;
249 static const int fsize=400;
259 char a_reason[rsize];
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,
314 err_hnd->
set(desc,file,line,errnum);
326 #ifdef O2SCL_NEVER_DEFINED 333 #define O2SCL_ASSERT(ev) \ 334 do { if (ev!=0) { std::cout << "O2scl: Macro err_assert() causing exit" \ 335 << " from error " << ev << " at " \ 336 << __LINE__ << " in file:\n " \ 337 << __FILE__ << std::endl; \ 338 std::cout << "Error handler string:\n " << err_hnd->get_str() \ 339 << std::endl; exit(ev); } } while (0) 344 #define O2SCL_BOOL_ASSERT(ev,str) \ 345 do { if (ev==false) { \ 346 std::cout << "O2scl: Macro bool_assert() causing exit at line " \ 347 << __LINE__ << " in file:\n " \ 348 << __FILE__ << std::endl; \ 349 std::cout << "Given string: " << str \ 350 << std::endl; exit(-1); } } while (0) 354 #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].
The main O<span style='position: relative; top: 0.3em; font-size: 0.8em'>2</span>scl O$_2$scl names...
err_hnd_gsl alt_err_hnd
An alternate GSL-like error handler.
err_hnd_type * err_hnd
The global error handler pointer.
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
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.
virtual const char * type() const
Return type ("err_hnd_gsl")
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.
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.
int a_errno
The error number.
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.
int a_line
The line number.
problem with user-supplied function
virtual void set(const char *reason, const char *file, int line, int lerrno)=0
Set an error.
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 const char * get_file() const =0
Return the file name of the last error.
user specified an invalid tolerance
failed because of roundoff error
integral or series is divergent
cannot reach the specified tolerance in f