JavaGetLastException Function

Action

Retrieves the last exception message.

Include file

Java.bdh

Syntax

JavaGetLastException( in  hHandle     : number,
                      out sBuffer     : string,
                      in  nBufferSize : number optional ): boolean;

Return value

  • true if the method call was successful, false otherwise

  • false otherwise

Parameter Description
hHandle Can be a handle to a java object or JAVA_STATIC_METHOD.
sBuffer Buffer to retrieve the last exception message.
nBufferSize (optional) Maximum number of bytes to retrieve.

Example

var
  hTestObj    : number; 

dcltrans
  transaction TInit
  begin
    JavaCreateJavaVM();
    hTestObj := JavaLoadObject("TestClass");
  end TInit;

  transaction TException
  var
    sBuffer : string;
    bRetVal : boolean;
  begin
    JavaRegisterException(500, "java.lang.RuntimeException");
    ErrorAdd(FACILITY_NATIVE_JAVA, 500, SEVERITY_INFORMATIONAL);
    bRetVal := JavaCallMethod(hTestObj, "doException");
    JavaGetLastException(hTestObj, sBuffer);

    if not bRetVal then
      Print(sBuffer);
    end;
  end TException;