Execute Lisp code with a catch for Java exceptions.
lw-ji
catching-java-exceptions &body body
catching-exceptions-bind (result exception) form &body body
body⇩ |
Lisp code. |
result⇩ |
A variable. |
exception⇩ |
A variable. |
form⇩ |
A Lisp form. |
The macro catching-java-exceptions
executes body with a catch for Java exceptions. The code of body is executed normally, and if no Java exception is signaled through the execution, returns whatever body returns. If there is an exception, instead of signaling an error of class java-exception, catching-java-exceptions
returns two values: nil
and the Java exception object (analogous to cl:ignore-errors).
The macro catching-exceptions-bind
executes form and binds result and exception to the first two return values if there was no exception. If there was an exception they are bound to nil
and the exception. It then executes the code of body within the scope of the bind. catching-exceptions-bind
is equivalent to:
(multiple-value-bind (result exception) (catching-java-exceptions form) body)
try
in Java code does). These macros do not affect the behavior for these cases, so even though when running under a Java debugger you may see an exception, it will not necessarily be visible with these macros.catching-java-exceptions
) or form (for catching-exceptions-bind
). They should normally be used in low-level code that actually does Java calls, with any Lisp error handlers wrapped around them.LispWorks® User Guide and Reference Manual - 01 Dec 2021 19:30:46