oscript.util
Class ErrorHandler

java.lang.Object
  extended byoscript.util.ErrorHandler
Direct Known Subclasses:
SwingErrorHandler

public abstract class ErrorHandler
extends java.lang.Object

The ErrorHandler is used by the interpreter to handle fatal, non-recoverable errors. When a fatal error occurs, the interpreter calls fatalError(java.lang.String), which is expected not to return.

Currently, the only fatal error is a corrupt symbol table. See issue #246 for the juicy details.

A default ErrorHandler is provided, which simply prints an error message to stderr and System.exit(int)s. Sometimes, such as in a GUI application where the user never sees stderr, you might want to implement your own error handler. There are two ways to do this:

Version:
1
Author:
Rob Clark (rob@ti.com)

Constructor Summary
ErrorHandler()
           
 
Method Summary
static void fatalError(java.lang.String str)
          Called in times of peril.
static ErrorHandler getErrorHandler()
          Get the fatal error handler.
static void setErrorHandler(ErrorHandler handler)
          Set the fatal error handler.
abstract  void showMessage(java.lang.String str)
          Display an error message to the user.
static void warning(java.lang.String str)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ErrorHandler

public ErrorHandler()
Method Detail

getErrorHandler

public static ErrorHandler getErrorHandler()
Get the fatal error handler. If it has not yet been set/loaded, this will cause it to be loaded by first trying to load the class specified by the oscript.error.handler property, and if that fails reverting to the default fatal error handler.


setErrorHandler

public static void setErrorHandler(ErrorHandler handler)
Set the fatal error handler.


fatalError

public static void fatalError(java.lang.String str)
Called in times of peril. This method should definately not return normally, and probably shouldn't return at all, ie. it should call System.exit(int), or sit in an infinite loop. (It may be possible to throw an exception, as long as care is taken to not throw anything that may be caught by the interpreter. And if you do keep the VM running, don't expect the ObjectScript interpreter to function.)

Parameters:
str - a string describing the error, how the user may correct the error, etc

warning

public static void warning(java.lang.String str)
Parameters:
str - a string describing the error, how the user may correct the error, etc

showMessage

public abstract void showMessage(java.lang.String str)
Display an error message to the user.

Parameters:
str - a string describing the error, how the user may correct the error, etc