XLISP > XLISP 2.0  -  Contents  -  Reference  -  Previous | Next

cerror


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

Syntax

(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 'cerror' function allows the generation of a continuable error. A continuable error is one that 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

From within the break loop , if a continue form is evaluated then a NIL is returned from 'cerror'. From within the break loop , forms can be evaluated to correct the error. If desired, the clean-up and top-level forms may be evaluated to abort out of the break loop.

Examples

(cerror "fee" "fi" "fo")            ; CERROR generates the message
                                    ;   error: fi - "fo"
                                    ;   if continued: fee

(cerror "I will do better"          ; CERROR generates the message
        "There's a problem, Dave")  ;   error: There's a problem, Dave
                                    ;   if continued: I will do better

                                    ; example of system generated correctable error
(symbol-value 'f)                   ;   error: unbound variable - F
                                    ;   if continued: try evaluating symbol again

Common Lisp: Common Lisp and XLISP have the same basic form and style for 'cerror'. However, the 'err-msg' and 'cont-msg' string in Common Lisp is sent to the format function. Although, XLISP does have the format function, it does not print the err-msg' with format. So, porting from XLISP to Common Lisp will work fine. When porting from Common Lisp to XLISP, you will need to check for this embedded control information in the error messages.

Note: In the XLISP system, the only correctable system errors have to do with the value of a symbol being unbound. In these cases, you can do a setq or set from within the break loop and then continue.

Note: Remember that *breakenable* needs to non-NIL for error and 'cerror' and system errors to be caught by the normal system break loop. If *breakenable* is NIL , error as well as 'cerror' and system errors can be caught by an errset form. If there is no surrounding errset , no error message is generated and the break loop is not entered.

See the cerror function in the XLISP 2.0 manual.

  Back to Top


XLISP > XLISP 2.0  -  Contents  -  Reference  -  Previous | Next