| igraph Reference Manual |
|---|
If an error happens, the functions in the library call the
IGRAPH_ERROR macro with a textual description of the error and an
igraph error code. This macro calls (through the igraph_error() function) the installed error handler. Another useful
macro is IGRAPH_CHECK(), this checks the return value of its
argument which is normally a function call, and calls IGRAPH_ERROR if it is not IGRAPH_SUCCESS.
#define IGRAPH_ERROR(reason,igraph_errno)
igraph functions usually use this macro when they notice an error.
It calls
igraph_error() with the proper parameters and if that returns
the macro returns the "calling" function as well, with the error
code. If for some (suspicious) reason you want to call the error
handler without returning from the current function, call
igraph_error() directly.
Arguments:
|
Textual description of the error. This should be
something more explaning than the text associated with the error
code. Eg. if the error code is |
|
The igraph error code. |
int igraph_error(const char *reason, const char *file, int line, int igraph_errno);
igraph functions usually call this fuction (most often via the
IGRAPH_ERROR macro) if they notice an error.
It calls the currently installed error handler function with the
supplied arguments.
Arguments:
|
Textual description of the error. |
|
The source file in which the error was noticed. |
|
The number of line in the source file which triggered the error. |
|
The igraph error code. |
Returns:
the error code (if it returns) |
#define IGRAPH_CHECK(a)
Arguments:
|
An expression, usually a function call. |
Executes the expression and checks its value. If this is not
IGRAPH_SUCCESS, it calls IGRAPH_ERROR with
the value as the error code. Here is an example usage:
IGRAPH_CHECK(vector_push_back(&v, 100));
There is only one reason to use this macro when writing
igraph functions. If the user installs an error handler which
returns to the auxilary calling code (like igraph_error_handler_ignore and igraph_error_handler_printignore), and the igraph function
signalling the error is called from another igraph function
then we need to make sure that the error is propagated back to
the auxilary (ie. non-igraph) calling function. This is achieved
by using IGRAPH_CHECK on every igraph
call which can return an error code.
| << 4.1. Writing error handlers | 4.3. Deallocating memory >> |