Error Handling

Error codes

The GSL routines report an error whenever they cannot perform the task requested of them. For example, a root-finding function would return a non-zero error code if could not converge to the requested accuracy, or exceeded a limit on the number of iterations. Situations like this are a normal occurrence when using any mathematical library and you should check the return status of the functions that you call.

Whenever a routine reports an error the return value specifies the type of error. The return value is analogous to the value of the variable errno in the C library. The caller can examine the return code and decide what action to take, including ignoring the error if it is not considered serious.

The error code numbers in GSL as GSL_EDOM are defined in Ruby/GSL as Ruby constants under the GSL module. Here are some of them:

Error handler

In Ruby/GSL, the default GSL error handler is replaced by an other one which calls rb_raise(). Thus whenever a GSL routine reports a fatal error, a Ruby Exception is generated.


prev next

Reference index top