wrapper.logExceptions(true);By default exception messages will be send to the
err
stream, but it is possible to control how the exceptions are logged by implementing the ScriptLogger interface and setting the logger to the wrapper by:wrapper.setScriptLogger(<the logger>);
wrapper.addExceptionListener(<the listener>);The exception listener has three methods:
notified(String message, Throwable th)
method notifies the listener for any exception encountered during the execution of the scriptnotifiedFirst(ScriptRuntimeException exception, String extension)
method notifies the listener for the first exception encountered during the execution of the script. The provided notifiedFirst(ScriptRuntimeException
allows to get the StackTrace with optionnaly only the script stack elementsaborted(String message)
method notifies the listener for an abort of the scriptgetScriptState()
method return the state of the listener:STATE_OK
. It is the responsability of the listener to implement correctly the notified
, notifiedFirst
, aborted
, and resetState
methods to be sure that the listener return its state correctly.
scriptHelperSwing.jar
file in your ClasspathScriptWrapper<Script> wrapper = new GroovyScriptWrapper() { } ... SwingExceptionListener listener = new SwingExceptionListener(); wrapper.addExceptionListener(listener);Then the first exception encountered during the compilation or execution of the script will popup the following window:
SwingExceptionListener
handles correctly the getScriptState()
method.scriptHelperSwing.jar
file in your ClasspathCopyright 2019-2020 Herve Girod. All Rights Reserved. Documentation and source under the BSD licence