[CppAD] CppAD Error Handler

Brad Bell bradbell at seanet.com
Wed Jan 4 07:55:19 EST 2006


The current version of the CppAD error handler
    http://www.coin-or.org/CppAD/Doc/cppaderror.htm
is a pair of macro calls
    CppADUnknownError(exp)
    CppADUsageError(exp, text)

These are being considered for deprecation or elimination.
If anyone is using these macros and the changes below would cause
problems for them, please reply to this posting.
| |
If a user chooses to redefine one or both of the macros above,
it must be redefined for all of the subroutines that the user links
with their program. Otherwise, one can not be sure which version
a the CppAD class is being linked (the one using the default
definition or the one using the users definition).

A better approach, that is more flexible and does not have this
problem is to have a default error handler routine that the user
can replace during execution instead of at compile time.

For example, an error handler could have the prototype
    void handler(bool known, int line, const char *file, const char *msg)
where known is true when the source of the error is known,
line is the source code line number,
file is the source code file, and
msg is the error message (which may be empty).

In this case a syntax like
    oldhandler = ErrorHandler(newhandler)
could replace the previous error handler with the new error handler.
This would allow the user to restore the previous handler when
the current context ends with the call
    ErrorHandler(oldhandler)




More information about the CppAD mailing list