Next: , Previous: Error Reporting, Up: Error Handling   [Index]


3.2 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. Error codes above 1024 are reserved for applications, and are not used by the library. 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,

Macro: int GSL_EDOM

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)

Macro: int GSL_ERANGE

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

Macro: int GSL_ENOMEM

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.

Macro: int GSL_EINVAL

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.

Function: const char * gsl_strerror (const int gsl_errno)

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.


Next: , Previous: Error Reporting, Up: Error Handling   [Index]