You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 22, 2023. It is now read-only.
Keith Poole edited this page Jul 15, 2016
·
6 revisions
Error handling is performed by the functions error, waserror, nexterror and poperror
The proc structure, accessed by externup() contains an array of Label structures (errlab), which is used
as a stack to hold the locations of error handlers.
waserror pushes the current location to the stack and returns zero.
error sets the error string and pops the topmost entry off the stack and transfers control to it with a return code of 1. In the code,it's the equivalent of waserror returning 1.
nexterror acts the same as error, but without changing the error string. This allows control to be passed to a higher level error handler.
poperror removes the top level handler. This must be called to remove any waserror calls in the current context.
Use
This example shows how these functions are used:
/* Get the Proc structure (must be called 'up') */Proc*up=externup();
/* save this location as an error handler */if (waserror()) {
/* * waserror returns 0 when it's called, and 1 if * 'returns' again via the Label */
... errorhandling ...
/* * optionally call the next handler in errlab. * (not needed if the error is handled here) */nexterror();
}
... codethatmightcallerror() ...
/* Remove the local handler */poperror();