casa
5.7.0-16
|
Manage exceptions that raises in ATM. More...
#include <ATMException.h>
Public Member Functions | |
Constructors and destructor | |
! | |
AtmException (const char *msg) throw () | |
Constructor. More... | |
AtmException (const char *file, const char *routine, int line, const char *msg) throw () | |
Constructor. More... | |
virtual | ~AtmException () throw () |
Destructor. More... | |
Get attributes | |
! | |
virtual const char * | file () const throw () |
Returns the file name where the current error raised. More... | |
virtual const char * | routine () const throw () |
Returns the routine name where the current error raised. More... | |
virtual int | line () const throw () |
Returns the line number where the current error raised. More... | |
virtual const char * | message () const throw () |
Returns the message where the current error raised. More... | |
virtual const char * | what () const throw () |
Returns a string describing the general cause of the current error. More... | |
Private Member Functions | |
Manage messages | |
! | |
string | formatMsg (const char *file, const char *routine, int line, const char *msg) |
Output a message that conform to a given trace pattern. More... | |
Private Attributes | |
string | file_m |
The file where the exception raised. More... | |
string | routine_m |
The routine where the exception raised. More... | |
int | line_m |
The line where the exception raised. More... | |
string | msg_m |
The message where the exception raised. More... | |
string | what_m |
The error message to be displayed. More... | |
Manage exceptions that raises in ATM.
To create a AtmException follow the example. The ATM_EXCEPTION_ARGS macro must be used to define the position (file, method and line) where the exception is raised. First include the header file for exceptions.
Then create an exception object in a try block. Possibly insert here a log message.
If you don't want to indicate the location in the log message then use the message() method instead of what(). Finally catch the exception.
In this catch block you can also modify the exception before throwing it. To do it remove the const keyword in the catch call.
The message may be formated using a stream. So first include the needed stream library.
Format the message like the following example where x is a variable of miscellaneous type. See following web links:
It is recommended to catch unknown exceptions with an AtmException.
To change the format of the outputed method, change the pattern of trace messages using the telcal::Trace::setTracePattern() method.
Definition at line 118 of file ATMException.h.
AtmException::AtmException | ( | const char * | msg | ) | |
throw | ( | ||||
) |
Constructor.
msg | a message that describes the exception. |
AtmException::AtmException | ( | const char * | file, |
const char * | routine, | ||
int | line, | ||
const char * | msg | ||
) | |||
throw | ( | ||
) |
Constructor.
file | the file name where the exception raised. |
routine | the routine name where the exception raised. |
line | the line where the exception raised. |
msg | a message that describes the exception. |
This constructor define the AtmException::what_m attribute using the output string formatted with the formatMsg() method.
|
inlinevirtual |
Destructor.
Definition at line 145 of file ATMException.h.
|
inlinevirtual |
Returns the file name where the current error raised.
Definition at line 158 of file ATMException.h.
References file_m.
|
private |
Output a message that conform to a given trace pattern.
file | a file name. |
routine | a routine name. |
line | a line number. |
msg | a message. |
|
inlinevirtual |
Returns the line number where the current error raised.
Definition at line 169 of file ATMException.h.
References line_m.
|
inlinevirtual |
Returns the message where the current error raised.
Definition at line 174 of file ATMException.h.
References msg_m.
|
inlinevirtual |
Returns the routine name where the current error raised.
Definition at line 163 of file ATMException.h.
References routine_m.
|
inlinevirtual |
Returns a string describing the general cause of the current error.
Definition at line 179 of file ATMException.h.
References what_m.
|
private |
The file where the exception raised.
Definition at line 199 of file ATMException.h.
Referenced by file().
|
private |
The line where the exception raised.
Definition at line 201 of file ATMException.h.
Referenced by line().
|
private |
The message where the exception raised.
Definition at line 202 of file ATMException.h.
Referenced by message().
|
private |
The routine where the exception raised.
Definition at line 200 of file ATMException.h.
Referenced by routine().
|
private |
The error message to be displayed.
Definition at line 203 of file ATMException.h.
Referenced by what().