|
EPICS ARCHIVER V4
|
Generic Exception: Base class for exceptions. More...
#include <GenericException.h>
Public Member Functions | |
| GenericException (const char *sourcefile, size_t line) | |
| Construct with file and line info. | |
| GenericException (const char *sourcefile, size_t line, const char *format,...) __attribute__((format(printf | |
| Construct with file, line info and printf-type arguments. | |
| virtual | ~GenericException () throw () |
| Virtual destructor to allow inheritance. | |
| virtual const char * | what () const throw () |
| Retrieve an explanatory string. More... | |
| const char * | getSourceFile () const |
| Source file where exception was thrown. | |
| size_t | getSourceLine () const |
| Line in source file where exception was thrown. | |
| const std::string & | getDetail () const |
| Return detail text (if set) | |
Generic Exception: Base class for exceptions.
An exception that provided info text with sourcefile & line information.
All exceptions should be thrown as an object/reference, not pointer, and also caught by reference, to avoid unnecessary copies and assert de-allocation:
try
{
... throw GenericException(__FILE__, __LINE__, "Trouble at mill!");
}
catch (GenericException &e)
{
... somehow print e.what() ...
}
(According to Scott Meyers "More Effective C++", a copy will be thrown, but Visual C++ seems to efficiently throw without copying).
It's a good idea to print the exception information as given above with the e.what() - string on a new line. That line will then usually read "filename (line-#)" and this format allows easy lookup from within IDEs. The error string might include newlines and usually also ends in one.
|
virtual | |||||||||||||
Retrieve an explanatory string.
Default implementation will print source file and line.
1.8.5