|
ccgsl 2.7.2
C++wrappersforGnuScientificLibrary
|
This class is used to handle gsl exceptions so that gsl can use these rather than the GSL error handling. More...
#include <exception.hpp>

Public Types | |
| enum | { GSL_SUCCESS = 0 , GSL_FAILURE = -1 , GSL_CONTINUE = -2 , GSL_EDOM = 1 , GSL_ERANGE = 2 , GSL_EFAULT = 3 , GSL_EINVAL = 4 , GSL_EFAILED = 5 , GSL_EFACTOR = 6 , GSL_ESANITY = 7 , GSL_ENOMEM = 8 , GSL_EBADFUNC = 9 , GSL_ERUNAWAY = 10 , GSL_EMAXITER = 11 , GSL_EZERODIV = 12 , GSL_EBADTOL = 13 , GSL_ETOL = 14 , GSL_EUNDRFLW = 15 , GSL_EOVRFLW = 16 , GSL_ELOSS = 17 , GSL_EROUND = 18 , GSL_EBADLEN = 19 , GSL_ENOTSQR = 20 , GSL_ESING = 21 , GSL_EDIVERGE = 22 , GSL_EUNSUP = 23 , GSL_EUNIMPL = 24 , GSL_ECACHE = 25 , GSL_ETABLE = 26 , GSL_ENOPROG = 27 , GSL_ENOPROGJ = 28 , GSL_ETOLF = 29 , GSL_ETOLX = 30 , GSL_ETOLG = 31 , GSL_EOF = 32 } |
| Enumerated type. More... | |
Public Member Functions | |
| exception (char const *reason, char const *file, int line, int gsl_errno) | |
| The constructor takes the same paramters as a GSL error handler: a description of the reason for the error, a file name, a line number, and an error number. More... | |
| char const * | get_reason () const |
| Get the message explaining the reason for the error/exception. More... | |
| char const * | get_file () const |
| Get the name of the file that caused an exception. More... | |
| int | get_line () const |
| Get the line number at which a GSL error handler caused the exception. More... | |
| int | get_gsl_errno () const |
| Get an error number. More... | |
| char const * | strerror () const |
| Get a standard GSL message corresponding to the error number. More... | |
Static Public Member Functions | |
| static void | enable () |
| Set the handler function to handle exceptions. More... | |
Static Public Attributes | |
| static void(*)(char const *, char const *, int, int) | set_handler (void(*handler)(char const *, char const *, int, int)) |
| Set the handler function. More... | |
| static void(*)(char const *, char const *, int, int) | set_handler_gsl_exceptions () |
| Set the handler function to handle exceptions. More... | |
| static void(*)(char const *, char const *, int, int) | set_handler_off () |
| Set the handler function to a null handler. More... | |
Static Private Member Functions | |
| static void | handler_gsl_exceptions (char const *reason, char const *file, int line, int gsl_errno) |
| The default exception handler for gsl. More... | |
| static void | handler_off (char const *, char const *, int, int) |
| The empty exception handler for gsl. More... | |
Private Attributes | |
| char const * | reason |
| A message giving a reason for this exception. More... | |
| char const * | file |
| The file that cause this exception. More... | |
| int const | line |
| The line number in file at which exception handler was called. More... | |
| int const | gsl_errno |
| A number indicating error type. More... | |
This class is used to handle gsl exceptions so that gsl can use these rather than the GSL error handling.
It defines its own error handler that throws exceptions. But the default behaviour is to rely on the error handling of GSL. Typically C++ users should use
early in their programmes to enable exception handling. Then if a GSL function calls the error handler, you should put this function in a try block and catch gsl::exception objects.
To enable and catch the exceptions, use code like the following.
The gsl default handler prints a short message to std::clog. You can change this by deriving your own subclass of exception, say my_exception and create a function, say
Then use
instead of
so that GSL uses your handler to create exceptions of class my_exception.
Definition at line 387 of file exception.hpp.
| anonymous enum |
Enumerated type.
Definition at line 468 of file exception.hpp.
|
inline |
The constructor takes the same paramters as a GSL error handler: a description of the reason for the error, a file name, a line number, and an error number.
| reason | A message explaining the reason for the exception |
| file | The name of the file that called the error handler and so created the exception |
| line | The line number within file |
| gsl_errno | An error number corresponding to the enum below |
Definition at line 398 of file exception.hpp.
References file, line, reason, and strerror().
Referenced by handler_gsl_exceptions().
|
inlinestatic |
Set the handler function to handle exceptions.
Use set_handler_gsl_exceptions if you want a pointer to the old handler.
Definition at line 452 of file exception.hpp.
References set_handler_gsl_exceptions.
|
inline |
Get the name of the file that caused an exception.
Definition at line 421 of file exception.hpp.
References file.
|
inline |
Get an error number.
Definition at line 432 of file exception.hpp.
References gsl_errno.
|
inline |
Get the line number at which a GSL error handler caused the exception.
Definition at line 426 of file exception.hpp.
References line.
|
inline |
Get the message explaining the reason for the error/exception.
Definition at line 416 of file exception.hpp.
References reason.
|
inlinestaticprivate |
The default exception handler for gsl.
| reason | A message explaining the reason for the exception |
| file | The name of the file that called the error handler and so created the exception |
| line | The line number within file |
| gsl_errno | An error number corresponding to the enum below |
Definition at line 514 of file exception.hpp.
References exception(), file, gsl_errno, line, and reason.
|
inlinestaticprivate |
The empty exception handler for gsl.
Definition at line 519 of file exception.hpp.
|
inline |
Get a standard GSL message corresponding to the error number.
Definition at line 437 of file exception.hpp.
References gsl_errno.
Referenced by exception().
|
private |
The file that cause this exception.
Definition at line 528 of file exception.hpp.
Referenced by exception(), get_file(), and handler_gsl_exceptions().
|
private |
A number indicating error type.
Definition at line 537 of file exception.hpp.
Referenced by get_gsl_errno(), handler_gsl_exceptions(), and strerror().
|
private |
The line number in file at which exception handler was called.
Definition at line 532 of file exception.hpp.
Referenced by exception(), get_line(), and handler_gsl_exceptions().
|
private |
A message giving a reason for this exception.
Definition at line 524 of file exception.hpp.
Referenced by exception(), get_reason(), and handler_gsl_exceptions().
|
inlinestatic |
Set the handler function.
This corresponds to gsl_set_error_handler and allows you to set your own error handler. Note that ccgsl provides a default error handler that throws exceptions of class exception.
| handler | The new handler |
Definition at line 446 of file exception.hpp.
|
inlinestatic |
Set the handler function to handle exceptions.
Definition at line 457 of file exception.hpp.
Referenced by enable().
|
inlinestatic |
Set the handler function to a null handler.
This disables any error handling.
Definition at line 463 of file exception.hpp.