LEDA tests the preconditions of many (not all!) operations. Preconditions are never tested, if the test takes more than constant time. If the test of a precondition fails an error handling routine is called. It takes an integer error number i and a char* error message string s as arguments. The default error handler writes s to the diagnostic output (cerr) and terminates the program abnormally if i! = 0. Users can provide their own error handling function handler by calling
set_error_handler(handler)After this function call handler is used instead of the default error handler. handler must be a function of type void handler(int, const char*). The parameters are replaced by the error number and the error message respectively.
New:
Starting with version 4.3 LEDA provides an exception error handler
void exception_error_handler(int num, const char* msg)
This handler uses the C++exception mechanism and throws an exception of
type leda_exception instead of terminating the program. An object of type
leda_exception stores a pair consisting of an error number and
an error message. Operations e.get_msg() and e.get_num() can be called to
retrieve the corresponding values from an exception object e.
Operations
#include < LEDA/system/error.h >