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 the args are 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.
LispWorks User Guide and Reference Manual - 13 Feb 2015