gpucalc::Exception Class Reference

When thrown, provides information about an error that has occurred inside the library. More...

#include <exception.h>

Inheritance diagram for gpucalc::Exception:

Inheritance graph

List of all members.

Public Member Functions

 Exception (const Exception &rhs)
 Copy constructor.
 Exception (int number, const Object &object, const std::string &description, const std::string &source, const char *type, const char *file, long line)
 Advanced constructor.
 Exception (int number, const Object &object, const std::string &description, const std::string &source)
 Default constructor.
virtual const std::string & getDescription () const
 Returns a string with only the 'description' field of this exception.
virtual const std::string & getFile () const
 gets source file name.
virtual const std::string & getFullDescription () const
 Returns a string with the full description of this error.
virtual long getLine () const
 gets line number.
virtual int getNumber () const throw ()
 gets the error code.
virtual const std::string & getSource () const
 gets the source function.
void operator= (const Exception &rhs)
 Assignment operator.
const char * what () const throw ()
 Override std::exception::what.
 ~Exception () throw ()
 Needed for compatibility with std::exception.

Protected Attributes

std::string mDescription
std::string mFile
std::string mFullDesc
long mLine
int mNumber
const ObjectmObject
std::string mSource
std::string mTypeName


Detailed Description

When thrown, provides information about an error that has occurred inside the library.

Remarks:
gpucalc never uses return values to indicate errors. Instead, if an error occurs, an exception is thrown, and this is the object that encapsulates the detail of the problem. The application using gpucalc should always ensure that the exceptions are caught, so all gpucalc library functions should occur within a try{} catch(gpucalc::Exception& e) {} block.
The user application should never create any instances of this object unless it wishes to unify its error handling using the same object.

Definition at line 87 of file exception.h.


Constructor & Destructor Documentation

gpucalc::Exception::Exception ( int  number,
const Object object,
const std::string &  description,
const std::string &  source 
)

Default constructor.

Definition at line 44 of file exception.cpp.

00044                                                                                                   :
00045    mLine(0), mObject(&object), mNumber(num), mDescription(desc), mSource(src)
00046  {
00047   // Log this error - not any more, allow catchers to do it
00048   //LogManager::getSingleton().logMessage(this->getFullDescription());
00049  }

gpucalc::Exception::Exception ( int  number,
const Object object,
const std::string &  description,
const std::string &  source,
const char *  type,
const char *  file,
long  line 
)

Advanced constructor.

Definition at line 52 of file exception.cpp.

00052                                                                                                                                                 :
00053   mLine(lin), mObject(&object), mNumber(num), mTypeName(typ), mDescription(desc), mSource(src), mFile(fil)
00054  {
00055   // Log this error, mask it from debug though since it may be caught and ignored
00056   if (LogManager::getSingletonPtr())
00057   {
00058    LogManager::getSingleton().logMessage(mObject, this->getFullDescription(), LML_Critical, true);
00059   }
00060  }

gpucalc::Exception::Exception ( const Exception rhs  ) 

Copy constructor.

Definition at line 63 of file exception.cpp.

00063                                           : std::exception(), mLine(rhs.mLine), mObject(rhs.mObject),
00064   mNumber(rhs.mNumber), mDescription(rhs.mDescription), mSource(rhs.mSource), mFile(rhs.mFile)
00065  {
00066  }

gpucalc::Exception::~Exception (  )  throw () [inline]

Needed for compatibility with std::exception.

Definition at line 126 of file exception.h.

00127    {
00128    }


Member Function Documentation

virtual const std::string& gpucalc::Exception::getDescription (  )  const [inline, virtual]

Returns a string with only the 'description' field of this exception.

Use getFullDescription() to get a full description of the error including line number, error number and what function threw the exception.

Definition at line 190 of file exception.h.

00191    {
00192     return mDescription;
00193    }

virtual const std::string& gpucalc::Exception::getFile (  )  const [inline, virtual]

gets source file name.

Definition at line 169 of file exception.h.

00170    {
00171     return mFile;
00172    }

const std::string & gpucalc::Exception::getFullDescription (  )  const [virtual]

Returns a string with the full description of this error.

Remarks:
The description contains the error number, the description supplied by the thrower, what routine threw the exception, and will also supply extra platform-specific information where applicable. For example - in the case of a 3rd party library error, the description of the error will include both the place in which gpucalc found the problem, and a text description from the 3rd party library, if available.

Definition at line 81 of file exception.cpp.

00082  {
00083   if (mFullDesc.empty())
00084   {
00085    std::ostringstream desc;
00086    desc << "EXCEPTION(" << mNumber << ":" << mTypeName << "): "
00087     << mDescription << " in " << mSource;
00088 
00089    if (mLine > 0)
00090    {
00091     desc << " at " << mFile << " (line " << mLine << ")";
00092    }
00093    mFullDesc = desc.str();
00094   }
00095   return mFullDesc;
00096  }

virtual long gpucalc::Exception::getLine (  )  const [inline, virtual]

gets line number.

Definition at line 178 of file exception.h.

00179    {
00180     return mLine;
00181    }

int gpucalc::Exception::getNumber (  )  const throw () [virtual]

gets the error code.

Definition at line 99 of file exception.cpp.

00100  {
00101   return mNumber;
00102  }

virtual const std::string& gpucalc::Exception::getSource (  )  const [inline, virtual]

gets the source function.

Definition at line 160 of file exception.h.

00161    {
00162     return mSource;
00163    }

void gpucalc::Exception::operator= ( const Exception rhs  ) 

Assignment operator.

Definition at line 69 of file exception.cpp.

00070  {
00071   mDescription = rhs.mDescription;
00072   mNumber = rhs.mNumber;
00073   mSource = rhs.mSource;
00074   mFile = rhs.mFile;
00075   mLine = rhs.mLine;
00076   mObject = rhs.mObject;
00077   mTypeName = rhs.mTypeName;
00078  }

const char* gpucalc::Exception::what (  )  const throw () [inline]

Override std::exception::what.

Definition at line 199 of file exception.h.

00200    {
00201     return getFullDescription().c_str();
00202    }


Member Data Documentation

std::string gpucalc::Exception::mDescription [protected]

Definition at line 94 of file exception.h.

std::string gpucalc::Exception::mFile [protected]

Definition at line 96 of file exception.h.

std::string gpucalc::Exception::mFullDesc [mutable, protected]

Definition at line 97 of file exception.h.

long gpucalc::Exception::mLine [protected]

Definition at line 90 of file exception.h.

int gpucalc::Exception::mNumber [protected]

Definition at line 92 of file exception.h.

const Object* gpucalc::Exception::mObject [protected]

Definition at line 91 of file exception.h.

std::string gpucalc::Exception::mSource [protected]

Definition at line 95 of file exception.h.

std::string gpucalc::Exception::mTypeName [protected]

Definition at line 93 of file exception.h.


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

Generated on Thu Mar 5 22:36:43 2009 for gpucalc by  doxygen 1.5.6