Nyquist / XLISP 2.0  -  Contents | Tutorials | Examples | Reference

error, cerror


Type:   -   function (subr)
Source:   -   xlbfun.c, xldbug.c

Syntax

(error err-msg [arg])
err-msg - a string expression for the error message
arg - an optional argument expression, printed after the error message
returns - never returns
(cerror cont-msg err-msg [arg])
cont-msg - a string expression for the continue message
err-msg - a string expression for the error message
arg - an optional argument expression, printed after the error message
returns - NIL when continued from the Break Loop

Description

The 'error' function allows the generation of a non-correctable error. A non-correctable error requires evaluation of a clean-up or top-level function from within the XLISP Break Loop to return to normal execution. The form of the message generated is:

error: err-msg - arg

If a continue function is evaluated within the Break Loop, then a an error message is generated:

error: this error can't be continued

There is no return from the 'error' function.

The 'cerror' function allows the generation of a correctable error. A correctable error can be corrected by some action within the XLISP Break Loop. The form of the message generated is:

error: err-msg - arg
if continued: cont-msg

In the Break Loop, forms can be evaluated to correct the error. If a continue function is evaluated within the Break Loop, then NIL is returned from 'cerror'. If desired, the clean-up and top-level forms may be evaluated to abort out of the Break Loop.

Note: The *breakenable* variable needs to be non-NIL for 'error', 'cerror' and system errors to be caught by the Nyquist/XLISP Break Loop.

Examples

Example of a non-correctable error:

> (error "invalid argument" "arg")
error: invalid argument - "arg"

1> (continue)   ; the 1 before the > indicates a break loop
error: this error can't be continued

1> (clean-up)
[ back to previous break level ]

>               ; no break loop any longer

Example of system generated correctable error:

> (symbol-value 'f)
error: unbound variable - F
if continued: try evaluating symbol again

1> (setq f 123)   ; the 1 before the > indicates a break loop
123               ; return value of (setq f 123)

1> (continue)
123               ; return value of (symbol-value 'f)

>                 ; no break loop any longer

See also:

  Back to Top


Nyquist / XLISP 2.0  -  Contents | Tutorials | Examples | Reference