All Manuals > LispWorks® User Guide and Reference Manual > 39 The LW-JI Package

throw-an-exception Function


Throws a Java exception from a proxy method invocation.




throw-an-exception exception-class-or-exception &rest args

A string or a Java object.
Lisp objects.

The function throw-an-exception throws a Java exception from a proxy method invocation.

throw-an-exception must be called inside the function that is invoked from a proxy, otherwise a Lisp error is signaled. It causes throwing of a Java exception from the call.

exception-class-or-exception can be either a string naming an exception class or a Java object of an exception class. When it is a string, throw-an-exception constructs an exception of this class using args as arguments (same as create-java-object). If exception-class-or-exception is an exception then args is ignored.

throw-an-exception throws in the Lisp sense out of your code, thus executing unwinding forms of surrounding cl:unwind-protect, and only then actually does the Java throwing (using JNI).

throw-an-exception can be used with the exception that is caught by catching-java-exceptions, if it is desired that the exception will be handled by the Java caller to the proxy. It is also needed when the method is documented to throw a specific exception in some situation.

See also

15.3.2 Using proxies

LispWorks® User Guide and Reference Manual - 01 Dec 2021 19:30:46