Function java_last_exception_get
Return the last stored Java exception.
The last stored Java exception is the first undeclared java.lang.RuntimeException or java.lang.Error after the last java_last_exception_clear() invocation or, if no RuntimeException/Error occured, the last declared exception reported via the script engine's try/catch mechanism.
Useful for script engines which do not support try/catch or if
you want to handle java.lang.RuntimeException or java.lang.Error
in your PHP code.
Note the distinction between java.lang.Exception, which can be
caught on PHP level, and
java.lang.RuntimeException/java.lang.Error, which raise a fatal PHP
error at the end of the php script (unless the error condition is
cleared using java_last_exception_clear()).
java.lang.Exception is a typical exception in your business logic,
java.lang.RuntimeException is an exception caused by a bug in your
program, for example java.lang.NullPointerException.
java.lang.Error marks a serious problem, for example
java.lang.OutOfMemoryError.
Example:
define ("JAVA_PREFER_VALUES", false); require_once("http://localhost:8080/JavaBridge/java/Java.inc"); try { new java("java.lang.String", null); // raises java.lang.RuntimeException assert (is_null(java_last_exception_get()); } catch (JavaException $e) { echo $e; }
Author: Jost Boekemeier
See:
java_last_exception_clear()
See: JAVA_PREFER_VALUES
Located at JavaProxy.inc
mixed
|
The last stored Java exception or null |