Base class for exceptions in the SDHLibrary-CPP. More...
#include <sdhexception.h>
Public Member Functions | |
cSDHLibraryException (char const *_type, cMsg const &_msg) | |
virtual const char * | what () const throw () |
Protected Attributes | |
cMsg | msg |
The message object. |
Base class for exceptions in the SDHLibrary-CPP.
At construction time a cMsg object is stored in the msg member of the cSDHLibraryException object. The cMsg object should contain a string wich further describes the actual cause of the exception thrown. The string in the cMsg object can be queried with the overloaded what() member function, just like in the std::exception class.
See the verbose description of the constructor #SDH::cSDHLibraryException::cSDHLibraryException() for examplary use.
Definition at line 132 of file sdhexception.h.
cSDHLibraryException::cSDHLibraryException | ( | char const * | _type, |
cMsg const & | _msg | ||
) |
Constructor of sdh exception base class.
_type | - the type name of the exception. By convention this is the class name of the exception |
_msg | - a reference to a cMsg object that further describes the exception. |
... if ( v > v_max ) throw new cSDHLibraryException( "cSDHLibraryException", cMsg( "Failed since v is invalid (v=%d > %d=v_max)", v, v_max ) );
// Derived exception class for more specific exceptions: class VCC_EXPORT cDerivedException : public cSDHLibraryException { public: cDerivedException( cMsg const & _msg ) : cSDHLibraryException( "cDerivedException", _msg ) {} } // (Yes that is really all that must be done here!) ... try { ... if ( v > v_max ) throw new cDerivedException( cMsg( "Failed since v is invalid (v=%d > %d=v_max)", v, v_max ) ); ... } catch ( cDerivedException *e ) { cerr << "Caught exception " << e->what() << "\n"; // handle exception ... // finally delete the caught exception delete e; }
virtual const char* cSDHLibraryException::what | ( | ) | const throw () [virtual] |
Return the msg member
cMsg cSDHLibraryException::msg [protected] |
The message object.
Definition at line 137 of file sdhexception.h.