Node:Error Codes, Next:, Previous:Error Reporting, Up:Error Handling



Error Codes

The error code numbers returned by library functions are defined in the file gsl_errno.h. They all have the prefix GSL_ and expand to non-zero constant integer values. Many of the error codes use the same base name as the corresponding error code in the C library. Here are some of the most common error codes,

int GSL_EDOM Macro
Domain error; used by mathematical functions when an argument value does not fall into the domain over which the function is defined (like EDOM in the C library)

int GSL_ERANGE Macro
Range error; used by mathematical functions when the result value is not representable because of overflow or underflow (like ERANGE in the C library)

int GSL_ENOMEM Macro
No memory available. The system cannot allocate more virtual memory because its capacity is full (like ENOMEM in the C library). This error is reported when a GSL routine encounters problems when trying to allocate memory with malloc.

int GSL_EINVAL Macro
Invalid argument. This is used to indicate various kinds of problems with passing the wrong argument to a library function (like EINVAL in the C library).

The error codes can be converted into an error message using the function gsl_strerror.

const char * gsl_strerror (const int gsl_errno) Function
This function returns a pointer to a string describing the error code gsl_errno. For example,
          printf ("error: %s\n", gsl_strerror (status));
          

would print an error message like error: output range error for a status value of GSL_ERANGE.