Topic: APLX Help : Help on APL language : System Functions & Variables : ⎕LE Last Exception
[ Previous | Next | Contents | Index | APL Home ]

www.microapl.co.uk

⎕LE Last Exception


Not implemented for APL internal classes or system classes

Syntax:

    error_message ← 'env' ⎕LE 0
    objectref ← 'env' ⎕LE 1

The system function ⎕LE can be used to get information about the most recent exception that was caught by APLX during a call to an external environment such as .Net or Java.

The left argument is a character vector which specifies the external environment for which you want exception information, in the same format as for ⎕NEW. The right argument is an integer which specifies which information you require:

CodeInformation returned
0Return the last error message associated with an exception in the specified environment
1Return a reference to the exception object

Once obtained, the object reference to the exception can be retained: it is unaffected by any subsequent exceptions. If no exception has ever occurred in the specified environment the error message is an empty character vector and a NULL object reference is returned.

Example using .NET

      ⍝ Do something which causes an exception
      date←'.net' ⎕NEW 'System.DateTime' 2008 02 16
      date.Year
2008
      date.Year←2009
Property Year is read-only
DOMAIN ERROR
      date.Year←2009
      ^

      ⍝ Use ⎕LE to investigate
      '.net' ⎕LE 0
Property Year is read-only
      exception←'.net' ⎕LE 1 
      exception.⎕CLASSREF
{.net:Exception}
      exception.Message
Property Year is read-only

Example using Java

      ⍝ Do something which causes an exception
      a←'java' ⎕NEW 'java.math.BigInteger' '123'
      a.testBit ¯3
Cannot call method
JVM: Exception in thread "main"
DOMAIN ERROR
      a.testBit ¯3
      ^

      ⍝ Use ⎕LE to investigate
      x←'java' ⎕LE 1
      x.⎕ds
java.lang.ArithmeticException: Negative bit address
      x.getStackTrace
[java:StackTraceElement]
      x.getStackTrace.⎕DS
[Ljava.lang.StackTraceElement;@ca0b6
      (x.getStackTrace).toString
 java.math.BigInteger.testBit(Unknown Source)

For the R interface, the right argument of 1 (exception object) is not supported, but the latest error message is.


Topic: APLX Help : Help on APL language : System Functions & Variables : ⎕LE Last Exception
[ Previous | Next | Contents | Index | APL Home ]