The Exception class is the base class from which all exception objects thrown in the library are derived. None of the functions in this class throws exceptions because an exception has probably already been thrown or is about to be thrown. Each exception object contains the following:
Exception provides all of the functions required for it and its derived classes, including functions that operate on the text strings in the stack.
Definition at line 151 of file Exception.hpp.
#include <Exception.hpp>
Public Types | |
enum | Severity { unrecoverable, recoverable } |
Exception severity classes. More... | |
Public Member Functions | |
Exception & | addLocation (const ExceptionLocation &location) |
Exception & | addText (const std::string &errorText) |
void | dump (std::ostream &s) const |
Exception () | |
Exception (const char *errorText, const unsigned long &errorId=0, const Severity &severity=unrecoverable) | |
Exception (const Exception &exception) | |
Copy constructor. More... | |
Exception (const std::string &errorText, const unsigned long &errorId=0, const Severity &severity=unrecoverable) | |
unsigned long | getErrorId () const |
Returns the error ID of the exception. More... | |
const ExceptionLocation | getLocation (const size_t &index=0) const |
size_t | getLocationCount () const |
std::string | getName () const |
Returns the name of the object's class. More... | |
std::string | getText (const size_t &index=0) const |
size_t | getTextCount () const |
Returns the number of text strings in the exception text stack. More... | |
bool | isRecoverable () const |
Exception & | operator= (const Exception &e) |
Assignment operator. More... | |
Exception & | setErrorId (const unsigned long &errId) |
Exception & | setSeverity (const Severity &sever) |
void | terminate () |
std::string | what () const |
Dump to a string. More... | |
~Exception () | |
Destructor. More... | |
Protected Member Functions | |
int | overflow (int c) |
Protected Attributes | |
unsigned long | errorId |
Error code. More... | |
std::vector< ExceptionLocation > | locations |
Stack of exception locations (where it was thrown). More... | |
Severity | severity |
Severity of exception. More... | |
std::vector< std::string > | text |
Text stack describing exception condition. More... | |
Private Attributes | |
std::string | streamBuffer |
Buffer for stream output. More... | |
Friends | |
std::ostream & | operator<< (std::ostream &s, const Exception &e) |
Exception severity classes.
Enumerator | |
---|---|
unrecoverable | program can not recover from this exception |
recoverable | program can recover from this exception |
Definition at line 155 of file Exception.hpp.
gnsstk::Exception::Exception | ( | ) |
Default constructor. Does nothing.
Definition at line 65 of file Exception.cpp.
gnsstk::Exception::Exception | ( | const std::string & | errorText, |
const unsigned long & | errorId = 0 , |
||
const Severity & | severity = unrecoverable |
||
) |
Full constructor for exception.
[in] | errorText | text message detailing exception. |
[in] | errorId | error code related to exception e.g. MQ result code. |
[in] | severity | severity of error. |
Definition at line 69 of file Exception.cpp.
gnsstk::Exception::Exception | ( | const char * | errorText, |
const unsigned long & | errorId = 0 , |
||
const Severity & | severity = unrecoverable |
||
) |
Full constructor for exception.
[in] | errorText | text message detailing exception. |
[in] | errorId | error code related to exception e.g. MQ result code. |
[in] | severity | severity of error. |
Definition at line 78 of file Exception.cpp.
Copy constructor.
Definition at line 87 of file Exception.cpp.
|
inline |
Destructor.
Definition at line 195 of file Exception.hpp.
Exception & gnsstk::Exception::addLocation | ( | const ExceptionLocation & | location | ) |
Adds the location information to the exception object. The library captures this information when an exception is thrown or rethrown. An array of ExceptionLocation objects is stored in the exception object.
[in] | location | An IExceptionLocation object containing the following:
|
Definition at line 108 of file Exception.cpp.
Appends the specified text to the text string on the top of the exception text stack.
[in] | errorText | The text you want to append. |
Definition at line 133 of file Exception.cpp.
void gnsstk::Exception::dump | ( | std::ostream & | s | ) | const |
Debug output function.
[in] | s | stream to output debugging information for this class to. |
Definition at line 157 of file Exception.cpp.
|
inline |
Returns the error ID of the exception.
Definition at line 212 of file Exception.hpp.
const ExceptionLocation gnsstk::Exception::getLocation | ( | const size_t & | index = 0 | ) | const |
Returns the ExceptionLocation object at the specified index.
[in] | index | If the index is not valid, a 0 pointer is returned. (well, not really since someone changed all this bah) |
Definition at line 115 of file Exception.cpp.
size_t gnsstk::Exception::getLocationCount | ( | ) | const |
Returns the number of locations stored in the exception location array.
Definition at line 128 of file Exception.cpp.
|
inline |
Returns the name of the object's class.
Definition at line 286 of file Exception.hpp.
string gnsstk::Exception::getText | ( | const size_t & | index = 0 | ) | const |
Returns an exception text string from the exception text stack.
[in] | index | The default index is 0, which is the top of the stack. If you specify an index which is not valid, a 0 pointer is returned. |
Definition at line 139 of file Exception.cpp.
size_t gnsstk::Exception::getTextCount | ( | ) | const |
Returns the number of text strings in the exception text stack.
Definition at line 152 of file Exception.cpp.
|
inline |
If the thrower (that is, whatever creates the exception) determines the exception is recoverable, 1 is returned. If the thrower determines it is unrecoverable, 0 is returned.
Definition at line 254 of file Exception.hpp.
Assignment operator.
Definition at line 95 of file Exception.cpp.
|
protected |
This is the streambuf function that actually outputs the data to the device. Since all output should be done with the standard ostream operators, this function should never be called directly. In the case of this class, the characters to be output are stored in a buffer and added to the exception text after each newline.
Definition at line 170 of file Exception.cpp.
Sets the error ID to the specified value.
[in] | errId | The identifier you want to associate with this error. |
Definition at line 220 of file Exception.hpp.
Sets the severity of the exception.
[in] | sever | Use the enumeration Severity to specify the severity of the exception. |
Definition at line 262 of file Exception.hpp.
|
inline |
Ends the application. Normally, the library only intends this function to be used internally by the library's exception-handling macros when the compiler you are using does not support C++ exception handling. This only occurs if you define the NO_EXCEPTIONS_SUPPORT macro.
Definition at line 208 of file Exception.hpp.
string gnsstk::Exception::what | ( | ) | const |
Dump to a string.
Definition at line 193 of file Exception.cpp.
|
protected |
Error code.
Definition at line 312 of file Exception.hpp.
|
protected |
Stack of exception locations (where it was thrown).
Definition at line 314 of file Exception.hpp.
|
protected |
Severity of exception.
Definition at line 316 of file Exception.hpp.
|
private |
Buffer for stream output.
Definition at line 332 of file Exception.hpp.
|
protected |
Text stack describing exception condition.
Definition at line 318 of file Exception.hpp.