MIRA
|
For detailed information see Error and Exception Handling
More...
Classes | |
class | CallStack |
Encapsulates unix call stack functionality. More... | |
class | Exception |
Base class for exceptions. More... | |
struct | IntSignal |
Structure used in signal handlers to pass the signal and callstack. More... | |
Macros | |
#define | MIRA_THROW(ex, msg) |
Macro for throwing an exception. More... | |
#define | MIRA_THROW_NOSTACK(ex, msg) |
Same as MIRA_THROW, except that no stack trace information is stored. More... | |
#define | MIRA_THROW_EXTSTACK(ex, msg, stack, thread) |
Same as MIRA_THROW, except that the stack trace information that is stored is provided externally. More... | |
#define | MIRA_RETHROW(ex, msg) |
Macro for rethrowing an exception with file and line information and for adding additional information. More... | |
#define | MIRA_DEFINE_EXCEPTION(Ex, Base) |
Macro for easily defining a new compatible exception class. More... | |
#define | MIRA_DEFINE_SERIALIZABLE_EXCEPTION(Ex, Base) |
Macro for easily defining a new serializable exception class. More... | |
Functions | |
void MIRA_BASE_EXPORT | installSignalHandler (int sig, boost::function< void(const IntSignal &)> function) |
Registers a function for the specified interrupt signal. More... | |
For detailed information see Error and Exception Handling
#define MIRA_THROW | ( | ex, | |
msg | |||
) |
Macro for throwing an exception.
The macro additionally stores the filename and the line of the source file where the exception was thrown. Additional information for the user can be specified as stream in the second macro parameter.
Example:
#define MIRA_THROW_NOSTACK | ( | ex, | |
msg | |||
) |
Same as MIRA_THROW, except that no stack trace information is stored.
This macro can be used when many exceptions are thrown and catched and no stack information is necessary, to avoid performance penalties.
#define MIRA_THROW_EXTSTACK | ( | ex, | |
msg, | |||
stack, | |||
thread | |||
) |
Same as MIRA_THROW, except that the stack trace information that is stored is provided externally.
This macro can be used when an exception is thrown to signal another original exception, e.g. in RPC handling.
#define MIRA_RETHROW | ( | ex, | |
msg | |||
) |
Macro for rethrowing an exception with file and line information and for adding additional information.
Example:
In the example the readValue() function is called for a file stream. readValue() will throw exceptions if the given stream violates certain syntax rules. The readFile() function below can now catch the exception in order to provide additional information like the filename or line number to the user. This information can be specified in the second parameter of MIRA_RETHROW.
#define MIRA_DEFINE_EXCEPTION | ( | Ex, | |
Base | |||
) |
Macro for easily defining a new compatible exception class.
Beside the name of the new exception class, the base class of the exception must be specified.
Example: The following example defines a new exception class XMyNewException that is derived from the XLogical exception.
#define MIRA_DEFINE_SERIALIZABLE_EXCEPTION | ( | Ex, | |
Base | |||
) |
Macro for easily defining a new serializable exception class.
Beside the name of the new exception class, the base class of the exception must be specified.
Example: The following example defines a new exception class XMyNewException that is derived from the XLogical exception.
void MIRA_BASE_EXPORT mira::installSignalHandler | ( | int | sig, |
boost::function< void(const IntSignal &)> | function | ||
) |
Registers a function for the specified interrupt signal.
The function can be a static member function or a member function that is binded using boost::bind(). The specified function must take a single int parameter where the signal is passed.
Example:
sig | The interupt signal |
function | The function that should be called if the signal occurs. |
To ensure compatibility with Windows the signal should be one of: