Previous Page | Next Page

Java Object Language Elements

EXCEPTIONCHECK Method



Determines whether an exception occurred during a method call.
Category: Exception

Syntax
Arguments
Details
Example
See Also

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

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


See Also

Method:

EXCEPTIONCLEAR Method

EXCEPTIONDESCRIBE Method

Previous Page | Next Page | Top of Page