Prev Next

@(@\newcommand{\B}[1]{ {\bf #1} } \newcommand{\R}[1]{ {\rm #1} }@)@
Exception Handling

Syntax
stored_message = error_message(input_message)

In Try Block
If input_message is not the empty string, it is stored in error_message and an exception is thrown. This is intended to be done inside a try block.

exception
The type of the exception is std::runtime_error which is derived from std::exception. If the standard exception what() is called, the return value will be the value of input_message when the exception was thrown.

In Catch Block
If input_message is the empty string, the most recently stored message in error_message is returned. In addition, the message is deleted from error_message. If there are no more messages stored in error_message, the empty string is returned. This is intended to be done inside a catch block.

Cppad Errors
Calls to the Cppad error handler get mapped to a call to error_message.

Not Thread Safe
The message storage is done using static information in error_message and hence is not thread safe.

Example
C++ , Octave , Perl , Python .
Input File: lib/error.cpp