Button for 1977 Button for 1984 Button for 1990 Button for 1995 Button for MDC Button for notes Button for examples
Left Hand Pointer

Error Processing

1995 Version of ANSI (Equivalent to Current ISO Version) of Standard

Right Hand Pointer

6.3.2 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.

An Error Processing transfer of control consists of an implicit Goto (without changing the PROCESS-STACK) to the following two lines of code where x is the value of $ETrap. These lines are implicitly incorporated into the current execution environment immediately preceding the next command in the normal execution sequence.

   ls x eol
   ls Quit:$Quit "" Quit  eol

For purposes of this transfer each command argument is considered to have its own commandword (see 8.1 General command rules)

An Error Processing transfer of control is performed when:

  1. The value of $ECode changes from an empty string to some other value as the result of an error or a Set 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 $STack($STack,"ECODE") returns a non-empty string and the value of $ECode changes to a non-empty string, the following actions are performed:

  1. It associates the $STack information about the failure as if it were associated with the frame identified by $STack+1.
  2. It transfers control to the following line of code; this line is implicitly incorporated into the current execution environment immediately preceding the next command in the normal execution sequence:
       ls TROllback:$TLevel  Quit:$Quit "" Quit  eol
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-2018 MUMPS Development Committee;
Copyright © Examples: 1995-2018 Ed de Moel;
Copyright © Annotations: 2003-2008 Jacquard Systems Research
Copyright © Annotations: 2008-2018 Ed de Moel.

This page most recently updated on 28-Nov-2011, 21:03:45 .

For comments, contact Ed de Moel (demoel@jacquardsystems.com)