#include <OTC/debug/excption.hh> class OTC_Exception {
public:
virtual ~OTC_Exception();
OTC_Exception(char const* theError=0);
OTC_Exception( char const* theError, char const* theFile, u_int theLine );
OTC_Exception(OTC_Exception const& theException);
inline char const* error() const;
inline char const* file() const;
inline u_int line() const;
virtual void display(ostream& outs) const;
static void throwException(OTC_Exception& theException);
static OTC_ThrowFunction setThrow(OTC_ThrowFunction theFunction);
};
ostream
.
The class does not make copies of the character strings it is
given, nor does it delete them. Thus, character strings passed to
the constructor of the class should be literal strings, or
otherwise be guaranteed not to be deleted.
OTC_Exception exception("Underflow");
throw exception;
catch (OTC_Exception const& exception)
{
exception.display(cerr);
terminate();
}
OTC_Exception(char const* theError=0);
theError
as the description of the
type of error which has occurred. If
theError
is 0
, a description of
"Unknown error"
is saved.
OTC_Exception(
char const* theError,
char const* theFile,
u_int theLine
);
theError
as the description of the
type of error which has occurred. If
theError
is 0
, a description of
"Unknown error"
is saved. theFile
and theLine
should be the name of the
file containing, and the line number in
the file, at which the code raising
the exception is located. These can be
generated using the preprocessor symbols
__FILE__
and __LINE__
.
OTC_Exception(OTC_Exception const& theException);
theException
.
inline char const* error() const;
inline char const* file() const;
0
if the name of the file
is not known.
inline u_int line() const;
0
if the line
in the file is not known.
virtual void display(ostream& outs) const;
outs
. This should be redefined
in derived class to first call the
base class version of the function, ie.,
OTC_Exception::display()
, and then
dump out any additional information which
is kept in the derived class. The derived
class must terminate each line of
information with an endl
.
static void throwException(OTC_Exception& theException);
theException
. If exceptions
are not supported by the compiler,
details of the exception are displayed
via the logger and terminate()
called.
static OTC_ThrowFunction setThrow(OTC_ThrowFunction theFunction);