Cryptography Reference
In-Depth Information
CHAPTER 16
Error Handling
O hateful error, melancholy's child!
—Shakespeare, Julius Caesar
16.1 (Don't) Panic ...
The C++ functions presented in the foregoing chapters embody mechanisms for
analyzing whether during the execution of a called C function an error or other
situation has occurred that requires a particular response or at least a warning.
The functions test whether the passed variables have been initialized and evaluate
the return value of the called C functions:
LINT f (LINT arg1, LINT arg2)
{
LINT result;
int err;
if (arg1.status == E_LINT_INV)
LINT::panic (E_LINT_VAL, "f", 1, __LINE__);
if (arg2.status == E_LINT_INV)
LINT::panic (E_LINT_VAL, "f", 2, __LINE__);
// Call C function to execute operation; error code is stored in err
err = f_l (arg1.n_l, arg2.n_l, result.n_l);
switch (err)
{
case 0:
result.status = E_LINT_OK;
break;
case E_CLINT_OFL:
result.status = E_LINT_OFL;
break;
case E_CLINT_UFL:
result.status = E_LINT_UFL;
break;
default:
LINT::panic (E_LINT_ERR, "f", err, __LINE__);
}
return result;
}
 
Search WWH ::




Custom Search