EXCEPTIONCHECK Method

Determines whether an exception occurred during a method call.

Category: Exception
Applies to: Java object

Syntax

object.EXCEPTIONCHECK (status);

Arguments

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.

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;
The following line is written to the SAS log:
exception