NAME
OTCERR_PreconditionFailure -
Exception class to be thrown for a failed precondition.
SYNOPSIS
#include <OTC/debug/precfail.hh>
class OTCERR_PreconditionFailure : public OTC_Exception
{
public:
~OTCERR_PreconditionFailure();
OTCERR_PreconditionFailure(
char const* theFile,
u_int theLine,
char const* theCondition,
char const* theDescription
);
OTCERR_PreconditionFailure(
OTCERR_PreconditionFailure const& theException
);
inline char const* condition() const;
inline char const* description() const;
void display(ostream& outs) const;
};
CLASS TYPE
Concrete
DESCRIPTION
This class is to be used when wishing to throw an exception for a
precondition failure. It is this exception which is thrown by
OTCLIB_ENSURE() when the condition fails. Typically, you would
not use this class directly, but would use OTCLIB_ENSURE().
If used explicitly this class would be used in the following
way:
if (!(somePointer != 0))
{
OTCERR_PreconditionFailure exception(
__FILE__,__LINE__,"somePointer != 0","some description"
);
throw exception;
}
The preferred method of using this class, is to write:
OTCLIB_ENSURE((somePointer != 0),"some description");
OTCLIB_ENSURE() cannot be compiled out of code. If a condition
check is only required during development the OTCLIB_ASSERT()
macro, which can be compiled out of code by defining NDEBUG
should be used.
INITIALISATION
OTCERR_PreconditionFailure(
char const* theFile,
u_int theLine,
char const* theCondition,
char const* theDescription
);
Creates an exception class with type
description "Precondition Failure", for
the failed condition theCondition.
theFile should be the name of the file;
supplied as __FILE__, and theLine
should be the line in the file; supplied
as __LINE__. theDescription should be
an English description of the failure
which has occurred.
OTCERR_PreconditionFailure(
OTCERR_PreconditionFailure const& theException
);
Uses the description of the exception from
theException.
QUERY
inline char const* condition() const;
Returns the condition that failed and
which resulted in the exception being
raised.
inline char const* description() const;
Returns the English description of the
failure.
DISPLAY
void display(ostream& outs) const;
Dumps a message which composes together
all the information about the error on the
stream outs.
SEE ALSO
OTC_Exception, OTCLIB_ASSERT, OTCLIB_ENSURE
LIBRARY
OTC
AUTHOR(S)
Graham Dumpleton
COPYRIGHT
Copyright 1992 1993 OTC LIMITED
Copyright 1994 DUMPLETON SOFTWARE CONSULTING PTY LIMITED