Home
Categories
Dictionnary
Download
Project Details
Changes Log
FAQ
License

ScriptExceptionListener


Exceptions encountered in the script may be encountered in several cases:
  • While trying to compile to script
  • While running the script
Exceptions are handled by a org.scripthelper.exceptions.ScriptExceptionListener. By default exceptions will be shown on the error stream.

ScriptExceptionListener API

The ScriptExceptionListener has three methods:
  • The notified(String message, Throwable th) method notifies the listener for any exception encountered during the execution of the script
  • The notifiedFirst(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 elements
  • The aborted(String message) method notifies the listener for an abort of the script

Swing exception listener

Rather than showing exceptions encountered in the scripts on the error stream, it is possible to set that they will be shown on an error window, with the associated Stack trace of the exception in the script.

You can specify the component which will show the exceptions by: ScriptManager.setScriptExceptionListener(ScriptExceptionListener) method.

The org.scripthelper.swing.SwingExceptionListener.SwingExceptionListener will show the StackTrace of the exception[1]
You will need to add scriptHelperSwing.jar in the classpath of your IDE to compile. You however don't need to put it on the classpath of your application, because scriptHelperSwing.jar is referenced in javaXUL.jar manifest
. For example:

      ScriptManager manager = new DefaultScriptManager();
      manager.setScriptExceptionListener(new SwingExceptionListener());      

Notes

  1. ^ You will need to add scriptHelperSwing.jar in the classpath of your IDE to compile. You however don't need to put it on the classpath of your application, because scriptHelperSwing.jar is referenced in javaXUL.jar manifest

Categories: api

Copyright 2008-2020 Herve Girod. All Rights Reserved. Documentation and source under the LGPL licence