![]() | ![]() | ![]() | with-error-handling | ![]() |
| ( form(:conditions type) ]) | [Macro] |
Purpose
Evaluate each
Package :gbbopen-tools
Module :gbbopen-tools
Arguments and values
form | A form | |
type | A type specifier (default is (and error (not
interrupt-signal)) error | |
handler-forms | Zero or more forms | |
error-forms | Zero or more forms | |
results | The values returned by evaluating form, the values
returned by evaluating the last |
Returns
The values returned by evaluating form unless an
error occurs during that evaluation in which case:
Description
If an error occurs while evaluating form, each
A lexical function,
Another lexical function,
The conditions that are handled can be changed by using the
(:conditions
type)
control-C
error
See also
*disable-with-error-handling*
Examples
> (with-error-handling (values 1 2 3) ':error-occurred) 1 2 3 > (with-error-handling (values 1 2 (error "Bad")) ':error-occurred) :error-occurred > (with-error-handling (values 1 2 (/ 10 0)) (printv (error-message)) nil) ;; (error-message) => "Attempt to divide 10 by zero." nil > (defparameter *x* 0) *x* > (with-error-handling ((let ((*x* 1)) (error "A silly error has occurred.")) (printv "Handler form" (error-message) *x*) (values :c :b :a)) (printv "Error form" (error-message) *x*) (values :a :b :c)) ;; Handler form ;; (error-message) => "A silly error has occurred." ;; *x* => 1 ;; Error form ;; (error-message) => "A silly error has occurred." ;; *x* => 0 :a :b :c > (with-error-handling ((let ((*x* 1)) (error "A silly error has occurred.")) (printv "Handler form" (error-message) *x*) (values :c :b :a))) ; No error forms ;; Handler form ;; (error-message) => "A silly error has occurred." ;; *x* => 1 :c :b :a > (with-error-handling ;; No handler-forms: ((let ((*x* 1)) (error "A silly error has occurred."))) (printv "Error form" (error-message) *x*) (values :a :b :c)) ;; Error form ;; (error-message) => "A silly error has occurred." ;; *x* => 0 :a :b :c > (with-error-handling (warn "Not too bad") ':error-occurred) ;; Warning: Not too bad nil > (with-error-handling ((warn "Not too bad") (:conditions (or (and error #+allegro (not interrupt-signal)) warning))) :error-occurred) :error-occurred >
The GBBopen Project
![]() | ![]() | ![]() | with-error-handling | ![]() |