Exception Class Reference
[Exception Classes]

#include <Exception.hpp>

List of all members.


Detailed Description

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.

See also:
exceptiontest.cpp for some examples of how to use this class.

Definition at line 155 of file Exception.hpp.

Public Types

enum  Severity { unrecoverable, recoverable }
 Exception severity classes. More...

Public Member Functions

 Exception () throw ()
 Default constructor.
 Exception (const std::string &errorText, const unsigned long &errorId=0, const Severity &severity=unrecoverable) throw ()
 Full constructor for exception.
 Exception (const char *errorText, const unsigned long &errorId=0, const Severity &severity=unrecoverable) throw ()
 Full constructor for exception.
 Exception (const Exception &exception) throw ()
 Copy constructor.
 ~Exception () throw ()
 Destructor.
Exceptionoperator= (const Exception &e) throw ()
 Assignment operator.
void terminate () throw ()
 Ends the application.
unsigned long getErrorId () const throw ()
 Returns the error ID of the exception.
ExceptionsetErrorId (const unsigned long &errId) throw ()
 Sets the error ID to the specified value.
ExceptionaddLocation (const ExceptionLocation &location) throw ()
 Adds the location information to the exception object.
const ExceptionLocation getLocation (const size_t &index=0) const throw ()
 Returns the ExceptionLocation object at the specified index.
size_t getLocationCount () const throw ()
 Returns the number of locations stored in the exception location array.
bool isRecoverable () const throw ()
 If the thrower (that is, whatever creates the exception) determines the exception is recoverable, 1 is returned.
ExceptionsetSeverity (const Severity &sever) throw ()
 Sets the severity of the exception.
ExceptionaddText (const std::string &errorText) throw ()
 Appends the specified text to the text string on the top of the exception text stack.
std::string getText (const size_t &index=0) const throw ()
 Returns an exception text string from the exception text stack.
size_t getTextCount () const throw ()
 Returns the number of text strings in the exception text stack.
std::string getName () const throw ()
 Returns the name of the object's class.
void dump (std::ostream &s) const throw ()
 Debug output function.
std::string what () const throw ()
 Dump to a string.

Protected Member Functions

int overflow (int c)
 This is the streambuf function that actually outputs the data to the device.

Protected Attributes

unsigned long errorId
 Error code.
std::vector< ExceptionLocationlocations
 Stack of exception locations (where it was thrown).
Severity severity
 Severity of exception.
std::vector< std::string > text
 Text stack describing exception condition.

Friends

std::ostream & operator<< (std::ostream &s, const Exception &e) throw ()
 Output stream operator for ::Exception.


Member Enumeration Documentation

enum Severity
 

Exception severity classes.

Enumeration values:
unrecoverable  program can not recover from this exception
recoverable  program can recover from this exception

Definition at line 159 of file Exception.hpp.


Constructor & Destructor Documentation

Exception  )  throw ()
 

Default constructor.

Does nothing.

Exception const std::string &  errorText,
const unsigned long &  errorId = 0,
const Severity severity = unrecoverable
throw ()
 

Full constructor for exception.

Parameters:
errorText text message detailing exception.
errorId error code related to exception e.g. MQ result code.
severity severity of error.

Exception const char *  errorText,
const unsigned long &  errorId = 0,
const Severity severity = unrecoverable
throw ()
 

Full constructor for exception.

Parameters:
errorText text message detailing exception.
errorId error code related to exception e.g. MQ result code.
severity severity of error.

Exception const Exception exception  )  throw ()
 

Copy constructor.

~Exception  )  throw () [inline]
 

Destructor.

Definition at line 202 of file Exception.hpp.


Member Function Documentation

Exception& addLocation const ExceptionLocation location  )  throw ()
 

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.

Parameters:
location An IExceptionLocation object containing the following:
  • Function name
  • File name
  • Line number where the function is called

Exception& addText const std::string &  errorText  )  throw ()
 

Appends the specified text to the text string on the top of the exception text stack.

Parameters:
errorText The text you want to append.

void dump std::ostream &  s  )  const throw ()
 

Debug output function.

Parameters:
s stream to output debugging information for this class to.

unsigned long getErrorId  )  const throw () [inline]
 

Returns the error ID of the exception.

Definition at line 222 of file Exception.hpp.

const ExceptionLocation getLocation const size_t &  index = 0  )  const throw ()
 

Returns the ExceptionLocation object at the specified index.

Parameters:
index If the index is not valid, a 0 pointer is returned. (well, not really since someone changed all this bah)

size_t getLocationCount  )  const throw ()
 

Returns the number of locations stored in the exception location array.

std::string getName  )  const throw () [inline]
 

Returns the name of the object's class.

Definition at line 306 of file Exception.hpp.

std::string getText const size_t &  index = 0  )  const throw ()
 

Returns an exception text string from the exception text stack.

Parameters:
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.

size_t getTextCount  )  const throw ()
 

Returns the number of text strings in the exception text stack.

bool isRecoverable  )  const throw () [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 269 of file Exception.hpp.

Exception& operator= const Exception e  )  throw ()
 

Assignment operator.

int overflow int  c  )  [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.

Exception& setErrorId const unsigned long &  errId  )  throw () [inline]
 

Sets the error ID to the specified value.

Parameters:
errId The identifier you want to associate with this error.

Definition at line 231 of file Exception.hpp.

Exception& setSeverity const Severity sever  )  throw () [inline]
 

Sets the severity of the exception.

Parameters:
sever Use the enumeration Severity to specify the severity of the exception.

Definition at line 278 of file Exception.hpp.

void terminate  )  throw () [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 217 of file Exception.hpp.

std::string what  )  const throw ()
 

Dump to a string.


Friends And Related Function Documentation

std::ostream& operator<< std::ostream &  s,
const Exception e
throw () [friend]
 

Output stream operator for ::Exception.

This is intended just to dump all the data in the ::Exception to the indicated stream.

Warning:
Warning: It will _not_ preserve the state of the stream.
Parameters:
s stream to send ::Exception information to.
e ::Exception to "dump".
Returns:
a reference to the stream s.


Member Data Documentation

unsigned long errorId [protected]
 

Error code.

Definition at line 334 of file Exception.hpp.

std::vector<ExceptionLocation> locations [protected]
 

Stack of exception locations (where it was thrown).

Definition at line 336 of file Exception.hpp.

Severity severity [protected]
 

Severity of exception.

Definition at line 338 of file Exception.hpp.

std::vector<std::string> text [protected]
 

Text stack describing exception condition.

Definition at line 340 of file Exception.hpp.


The documentation for this class was generated from the following file:
Generated on Tue May 21 03:31:49 2013 for GPS ToolKit Software Library by  doxygen 1.3.9.1