[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
10.1 Error Codes |
If an error occurs, Logo takes the following steps. First, if there is an
available variable named ERRACT
, Logo takes its value as an
instructionlist and runs the instructions. The operation ERROR
may be
used within the instructions (once) to examine the error condition. If the
instructionlist invokes PAUSE
, the error message is printed before the
pause happens. Certain errors are recoverable; for one of those errors,
if the instructionlist outputs a value, that value is used in place of the
expression that caused the error. (If ERRACT
invokes PAUSE
and
the user then invokes CONTINUE
with an input, that input becomes the
output from PAUSE
and therefore the output from the ERRACT
instructionlist.)
It is possible for an ERRACT
instructionlist to produce an
inappropriate value or no value where one is needed. As a result, the same
error condition could recur forever because of this mechanism. To avoid that
danger, if the same error condition occurs twice in a row from an
ERRACT
instructionlist without user interaction, the message
‘Erract loop’ is printed and control returns to toplevel. "Without user
interaction" means that if ERRACT
invokes PAUSE
and the user
provides an incorrect value, this loop prevention mechanism does not take
effect and the user gets to try again.
During the running of the ERRACT
instructionlist, ERRACT
is
locally unbound, so an error in the ERRACT
instructions themselves will
not cause a loop. In particular, an error during a pause will not cause a
pause-within-a-pause unless the user reassigns the value [PAUSE]
to
ERRACT
during the pause. But such an error will not return to
toplevel; it will remain within the original pause loop.
If there is no available ERRACT
value, Logo handles the error by
generating an internal THROW "ERROR. (A user program can also
generate an error condition deliberately by invoking THROW
.) If this
throw is not caught by a CATCH "ERROR in the user program, it is
eventually caught either by the toplevel instruction loop or by a pause loop,
which prints the error message. An invocation of CATCH "ERROR in a
user program locally unbinds ERRACT
, so the effect is that whichever of
ERRACT
and CATCH "ERROR is more local will take precedence.
If a floating point overflow occurs during an arithmetic operation, or a
two-input mathematical function (like POWER
) is invoked with an illegal
combination of inputs, the ‘doesn't like’ message refers to the second
operand, but should be taken as meaning the combination.
See section erract , throw , error , catch , pause , continue .
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Here are the numeric codes that appear as the first member of the list
output by ERROR
when an error is caught, with the corresponding messages.
Some messages may have two different codes depending on whether or not
the error is recoverable (that is, a substitute value can be provided
through the ERRACT
mechanism) in the specific context. Some messages are
warnings rather than errors; these will not be caught. Errors 0 and 32 are
so bad that Logo exits immediately.
0 Fatal internal error (can't be caught) 1 Out of memory 2 Stack overflow 3 Turtle out of bounds 4 proc doesn't like datum as input (not recoverable) 5 proc didn't output to proc 6 Not enough inputs to proc 7 |
[ << ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This document was generated by Brian Harvey on September, 3 2008 using texi2html 1.78.