Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Private Attributes | Friends | List of all members
gnsstk::Exception Class Reference

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 151 of file Exception.hpp.

#include <Exception.hpp>

Public Types

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

Public Member Functions

ExceptionaddLocation (const ExceptionLocation &location)
 
ExceptionaddText (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
 
Exceptionoperator= (const Exception &e)
 Assignment operator. More...
 
ExceptionsetErrorId (const unsigned long &errId)
 
ExceptionsetSeverity (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< ExceptionLocationlocations
 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)
 

Member Enumeration Documentation

◆ Severity

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.

Constructor & Destructor Documentation

◆ Exception() [1/4]

gnsstk::Exception::Exception ( )

Default constructor. Does nothing.

Definition at line 65 of file Exception.cpp.

◆ Exception() [2/4]

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

Full constructor for exception.

Parameters
[in]errorTexttext message detailing exception.
[in]errorIderror code related to exception e.g. MQ result code.
[in]severityseverity of error.

Definition at line 69 of file Exception.cpp.

◆ Exception() [3/4]

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

Full constructor for exception.

Parameters
[in]errorTexttext message detailing exception.
[in]errorIderror code related to exception e.g. MQ result code.
[in]severityseverity of error.

Definition at line 78 of file Exception.cpp.

◆ Exception() [4/4]

gnsstk::Exception::Exception ( const Exception exception)

Copy constructor.

Definition at line 87 of file Exception.cpp.

◆ ~Exception()

gnsstk::Exception::~Exception ( )
inline

Destructor.

Definition at line 195 of file Exception.hpp.

Member Function Documentation

◆ addLocation()

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.

Parameters
[in]locationAn IExceptionLocation object containing the following:
  • Function name
  • File name
  • Line number where the function is called

Definition at line 108 of file Exception.cpp.

◆ addText()

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

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

Parameters
[in]errorTextThe text you want to append.

Definition at line 133 of file Exception.cpp.

◆ dump()

void gnsstk::Exception::dump ( std::ostream &  s) const

Debug output function.

Parameters
[in]sstream to output debugging information for this class to.

Definition at line 157 of file Exception.cpp.

◆ getErrorId()

unsigned long gnsstk::Exception::getErrorId ( ) const
inline

Returns the error ID of the exception.

Definition at line 212 of file Exception.hpp.

◆ getLocation()

const ExceptionLocation gnsstk::Exception::getLocation ( const size_t &  index = 0) const

Returns the ExceptionLocation object at the specified index.

Parameters
[in]indexIf 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.

◆ getLocationCount()

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.

◆ getName()

std::string gnsstk::Exception::getName ( ) const
inline

Returns the name of the object's class.

Definition at line 286 of file Exception.hpp.

◆ getText()

string gnsstk::Exception::getText ( const size_t &  index = 0) const

Returns an exception text string from the exception text stack.

Parameters
[in]indexThe 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.

◆ getTextCount()

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.

◆ isRecoverable()

bool gnsstk::Exception::isRecoverable ( ) const
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.

◆ operator=()

Exception & gnsstk::Exception::operator= ( const Exception e)

Assignment operator.

Definition at line 95 of file Exception.cpp.

◆ overflow()

int gnsstk::Exception::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.

Definition at line 170 of file Exception.cpp.

◆ setErrorId()

Exception& gnsstk::Exception::setErrorId ( const unsigned long &  errId)
inline

Sets the error ID to the specified value.

Parameters
[in]errIdThe identifier you want to associate with this error.

Definition at line 220 of file Exception.hpp.

◆ setSeverity()

Exception& gnsstk::Exception::setSeverity ( const Severity sever)
inline

Sets the severity of the exception.

Parameters
[in]severUse the enumeration Severity to specify the severity of the exception.

Definition at line 262 of file Exception.hpp.

◆ terminate()

void gnsstk::Exception::terminate ( )
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.

◆ what()

string gnsstk::Exception::what ( ) const

Dump to a string.

Definition at line 193 of file Exception.cpp.

Friends And Related Function Documentation

◆ operator<<

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

Output stream operator for Exception. This is intended just to dump all the data in the Exception to the indicated stream.

Warning
It will not preserve the state of the stream.
Parameters
[in,out]sstream to send Exception information to.
[in]eException to "dump".
Returns
a reference to the stream s.

Member Data Documentation

◆ errorId

unsigned long gnsstk::Exception::errorId
protected

Error code.

Definition at line 312 of file Exception.hpp.

◆ locations

std::vector<ExceptionLocation> gnsstk::Exception::locations
protected

Stack of exception locations (where it was thrown).

Definition at line 314 of file Exception.hpp.

◆ severity

Severity gnsstk::Exception::severity
protected

Severity of exception.

Definition at line 316 of file Exception.hpp.

◆ streamBuffer

std::string gnsstk::Exception::streamBuffer
private

Buffer for stream output.

Definition at line 332 of file Exception.hpp.

◆ text

std::vector<std::string> gnsstk::Exception::text
protected

Text stack describing exception condition.

Definition at line 318 of file Exception.hpp.


The documentation for this class was generated from the following files:


gnsstk
Author(s):
autogenerated on Wed Oct 25 2023 02:40:44