Java Object Language Elements |
Determines whether an exception occurred during a method call.
object.EXCEPTIONCHECK(status);
|
- object
-
specifies the name of the java object.
- status
-
specifies the exception status that is returned.
Tip: |
The status value that is returned by Java
is of type DOUBLE which corresponds to a SAS numeric data value. |
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.
In the following example, the Java class contains a method that throws
an exception. The method is called in the DATA step and a check is made for
the 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;
The following line is written to the SAS log.
exception
Copyright © 2011 by SAS Institute Inc., Cary, NC, USA. All rights reserved.