Tip:The status value that is returned by Java is of type DOUBLE,
which corresponds to a SAS numeric data value.
Details
Java exceptions are
handled through the EXCEPTIONCHECK, EXCEPTIONCLEAR, and EXCEPTIONDESCRIBE
methods.
The EXCEPTIONCHECK method
is used to determine whether an exception occurred during a method
call. Ideally, the EXCEPTIONCHECK method should be called after every
call to a Java method that can throw an exception.
Example: Checking an Exception
In the following example,
the Java class contains a method that throws an exception. The DATA
step calls the method and checks for an exception.
/* Java code */
public class a
{
public void m() throws NullPointerException
{
throw new NullPointerException();
}
}
/* DATA step code */
data _null_;
length e 8;
dcl javaobj j('a');
rc = j.callvoidmethod('m');
/* Check for exception. Value is returned in variable 'e' */
rc = j.exceptioncheck(e);
if (e) then
put 'exception';
else
put 'no exception';
run;