The nsjava::throw Command


Usage:

nsjava::throw throwableObj

The nsjava::throw command throws a Java exception. throwableObj must be a valid Java object handle and must be an instance of java.lang.Throwable. Internally, the nsjava::throw command sets the errorCode global variable to a list whose first element is the string "JAVA" and whose second element is throwableObj. Then, it generates a Tcl error to cause the script to return abruptly. The effect of calling the nsjava::throw command is exactly the same as calling a Java method which throws a Java exception.

Example:

The following code will raise a java.lang.ClassNotFoundException.
nsjava::throw [nsjava::new ClassNotFoundException "bad class foo"]
Copyright © 1997-1998 Sun Microsystems, Inc.