Button for 1977 Button for 1984 Button for 1990 Button for 1995 Button for MDC Button for notes Button for examples

Error Processing

Draft MDC Standard

6.3.3 Error processing

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:

  1. The value of $ECode is updated to a non-empty value. This occurs when an error condition is detected or may be forced via the Set or Assign command.
  2. $ECode is not the empty string and a Quit command removes a PROCESS-STACK level at which $STack($STack,"ECODE") would return a non-empty string, and, at the new PROCESS-STACK level, $STack($STack,"ECODE") would return an empty string (in other words, when a Quit takes the process from a frame in which an error occurred to a frame where no error has occurred).

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:

  1. It associates the information about the failure as if it were associated with the frame identified by $STack+1.
  2. The following commands are implicitly incorporated into the current execution environment immediately preceding the next command in the normal execution sequence:
       TROllback:$TLevel  Quit:$Quit "" Quit  ;
Button for 1977 Button for 1984 Button for 1990 Button for 1995 Button for MDC Button for notes Button for examples

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)