☜ | Error ProcessingDraft MDC Standard | ☞ |
Error trapping provides a mechanism by which a process can execute specifiable commands in the event that $ECode becomes non-empty. The following facilities are provided:
The $ETrap special variable may be set to either the empty string or to code to be invoked when $ECode becomes non-empty. Stacking of the contents of $ETrap is performed via the New command.
$ECode provides information describing existing error conditions. $ECode is a comma-surrounded list of conditions.
The $STack function and $STack variable provide stack related information.
$EStack counts stack levels since $EStack was last Newed.
When an error condition is detected, the information about the error is appended to the current value of $ECode and to $STack($STack,"ECODE"). If appending to $ECode or $STack($STack,"ECODE") would exceed an implementation’s maximum string length, the implementation may choose which older information in $ECode or $STack($STack,"ECODE") to discard. The value of $ECode may also be replaced via the Set command.
An Error Processing transfer of control consists of terminating the current command and processing in the scope of any active For commands and indirection; and second, explicitly resuming execution at the same LEVEL with two lines where the body of the first line is the value of $ETrap and the body of the second line is:
Quit:$Quit "" Quit
The two lines are:
ls [li] x eol
ls [li] Quit:$Quit "" Quit eol
Where li represents the line level at the time of the transfer of control and x represents the value of $ETrap.
For purposes of this transfer each command argument is considered to have its own commandword (see 8.1 General command rules).
When an error condition is detected, the information about the error is appended to the current value of $ECode and to $STack($STack,"ECODE"). The value of $ECode may also be replaced via the Set command.
An Error Processing transfer of control is performed when:
When in the context of error processing (i.e., $STack($STack,"ECODE") returns a non-empty string) a new error condition occurs (i.e., the value of $ECode changes to a different non-empty string), the following actions are performed:
Copyright © Standard Documents; 1977-2024 MUMPS Development Committee;
Copyright © Examples: 1995-2024 Ed de Moel;
Copyright © Annotations: 2003-2008 Jacquard Systems Research
Copyright © Annotations: 2008-2024 Ed de Moel.
Some specifications are "approved for inclusion in a future standard". Note that the MUMPS Development Committee cannot guarantee that such future standards will indeed be published.
This page most recently updated on 17-Nov-2023, 10:36:48.
For comments, contact Ed de Moel (demoel@jacquardsystems.com)