next up previous contents index
Next: Files and Directories ( Up: Simple Data Types and Previous: Memory Allocator ( leda_allocator   Contents   Index


Error Handling ( error )

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. It 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, char*). The parameters are replaced by the error number and the error message respectively.

Operations

#include < LEDA/error.h >

void error_handler(int err_no, const char* msg)
    reports error messages by passing err_no and msg to the default error handler.

LedaErrorHandler set_error_handler(void (*err_handler)(int, const char*))
    sets the default error handler to function err_handler. Returns a pointer to the previous error handler.

void catch_system_errors(bool b=true)
    after a call to this function system errors ( e.g. bus errors and segmentation faults) are handled by LEDA's error handler.

bool leda_assert(bool cond, const char* err_msg, int err_no=0)
    calls error_handler(err_no,err_msg) if cond = false and returns cond.


next up previous contents index
Next: Files and Directories ( Up: Simple Data Types and Previous: Memory Allocator ( leda_allocator   Contents   Index
LEDA research project
2000-02-09