[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

*error-handler*



The variable *error-handler* is not documented in impnotes.txt.  Is it
likely to be preserved in future versions of CLISP?  I would like to be
able to use it in macros like this:

(defmacro with-handled-error (&body body)
  (let ((blockvar (gensym)))
    `(block ,blockvar
	    (let ((*error-handler*
		   #'(lambda (arg1 &rest args)
			     (apply 'format (cons *error-output* args))
			     (return-from ,blockvar nil))))
		 ,@body))))

The macro works like this:

> (with-handled-error (pathname "~nouser"))
UNIX error 2 (ENOENT): No such file or directory
NIL
> (with-handled-error (open "/dev/rrz0a" :direction :input))
UNIX error 13 (EACCES): Permission denied
NIL
>

What are the potential caveats in using *error-handler* this way?
Are there better ways in CLISP to deal with system errors in code?

-Calvin