Go up one levelGo to Previous Go to Next

Error Handling

Error handling consists mainly of two default library routines defined in the tclutil package: one for normal errors and one for system related errors that should include the system error text:

 
error(const char* msg1, const char* msg2, int code = 0); 
sys_error(const char* msg1, const char* msg2);

These routines are defaults that can be overridden by the application if they are defined there. The default versions for Tcl applications generate Tcl errors while the default versions for plain C/C++ applications print the messages on the stderr.

In any case, the error reporting routines keep a copy of the most recent error message, which can be retrieved using the getError() routine/method.

Routine

Description

error

Report the error.

fmt_error

Same as error , but with a printf like interface.

sys_error

Report the error with the system error code, like perror.

fmt_sys_error

same as sys_error , but with a printf like interface.

log_message

Used to log a message that is not an error (not used here).

last_error

Return the text of the previous error message.

last_error_code

Return the error code for the previous error.

clear_error

Reset the last_error buf to empty.

set_error_handler

Set a routine to be called when errors occur and return a pointer to the previous handler.

print_error

Simple default error handler: print the error message on stdout.

See the man page for error(3) in the tclutil package for details on the above routines.


Go up one levelGo to Previous Go to Next

Please send questions or comments to abrighto@eso.org@eso.org.
Copyright © 1998 ESO - European Southern Observatory