Cryptography Reference
In-Depth Information
class LINT_Init : public LINT_Error // function argument illegal or uninitialized
{
...
};
class LINT_Nullptr : public LINT_Error // null pointer passed as argument
{
...
};
class LINT_OFL : public LINT_Error // overflow in function
{
...
};
class LINT_UFL : public LINT_Error // underflow in function
{
...
};
With this we are in a position, on the one hand, to catch
LINT
errors without
distinguishing specifically which error has occurred by inserting a
catch
block
catch (LINT_Error const &err) // notice: LINT_Error is abstract
{
//
...
err.debug_print();
//
...
}
after a
try
block, while on the other hand we can carry on a goal-directed search
for an individual error by specifying the appropriate error class as argument in
the
catch
instruction.
One should note that as an abstract base class
LINT_Error
is not instantiatable
as an object, for which reason the argument
err
can be passed only by reference
and not by value. Although all the
LINT
functions have been equipped with the
panic()
instruction for error handling, the use of exceptions does not mean
that we must alter all the functions. Rather, we integrate the appropriate
throw
instructions into the
panic()
routine, where they are called in conjunction with
the error that has been reported. Control is then transferred to the
catch
block,
which belongs to the
try
block of the calling function. The following code segment
of the function
panic()
clarifies the modus operandi:
void LINT::panic (LINT_ERRORS error, const char* func,
int arg, int line, const char* file)
{
if (LINT_User_Error_Handler)
{
LINT_User_Error_Handler (error, func, arg, line, file);
}