[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

# 10. Error Processing

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] | [ ? ]

## 10.1 Error Codes

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	proc doesn't like datum as input  (recoverable)
      8	Too much inside ()'s
      9 	You don't say what to do with datum
     10	')' not found
     11	var has no value
     12	Unexpected ')'
     13	I don't know how to proc  (recoverable)
     14	Can't find catch tag for throwtag
     15	proc is already defined
     16	Stopped
     17	Already dribbling
     18	File system error
     19	Assuming you mean IFELSE, not IF  (warning only)
     20	var shadowed by local in procedure call  (warning only)
     21	Throw "Error
     22	proc is a primitive
     23	Can't use TO inside a procedure
     24	I don't know how to proc  (not recoverable)
     25	IFTRUE/IFFALSE without TEST
     26	Unexpected ']'
     27	Unexpected '}'
     28	Couldn't initialize graphics
     29	Macro returned value instead of a list
     30	You don't say what to do with value
     31	Can only use STOP or OUTPUT inside a procedure
     32	APPLY doesn't like badthing as input
     33	END inside multi-line instruction
     34	Really out of memory  (can't be caught)
     35	user-generated error message (THROW "ERROR message)
     36	END inside multi-line instruction
     37	Bad default expression for optional input: expr
     38	Can't use OUTPUT or STOP inside RUNRESULT
     39 	Assuming you meant 'FD 100', not FD100  (or similar)
     40	I can't open file filename
     41	File filename already open
     42	File filename not open
     43	Runlist [expr expr] has more than one expression.

[ << ] | [ >> ] |  |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

This document was generated by Brian Harvey on September, 3 2008 using texi2html 1.78.