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

throw-an-exception Function

Summary

Throws a Java exception from a proxy method invocation.

Package

lw-ji

Signature

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

Arguments
exception-class-or-exception
A string or a Java object.
args
Lisp objects.
Description

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

define-lisp-proxy
15.3.2 Using proxies


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