bsh

Class TargetError

public class TargetError extends EvalError

TargetError is an EvalError that wraps an exception thrown by the script (or by code called from the script). TargetErrors indicate exceptions which can be caught within the script itself, whereas a general EvalError indicates that the script cannot be evaluated further for some reason. If the exception is caught within the script it is automatically unwrapped, so the code looks like normal Java code. If the TargetError is thrown from the eval() or interpreter.eval() method it may be caught and unwrapped to determine what exception was thrown.
Constructor Summary
TargetError(String msg, Throwable t, SimpleNode node, CallStack callstack, boolean inNativeCode)
TargetError(Throwable t, SimpleNode node, CallStack callstack)
Method Summary
ThrowablegetTarget()
booleaninNativeCode()
Return true if the TargetError was generated from native code. e.g. if the script called into a compiled java class which threw the excpetion.
voidprintStackTrace()
voidprintStackTrace(PrintStream out)
voidprintStackTrace(boolean debug, PrintStream out)
StringprintTargetError(Throwable t)
Generate a printable string showing the wrapped target exception.
StringtoString()
StringxPrintTargetError(Throwable t)
Extended form of print target error.

Constructor Detail

TargetError

public TargetError(String msg, Throwable t, SimpleNode node, CallStack callstack, boolean inNativeCode)

TargetError

public TargetError(Throwable t, SimpleNode node, CallStack callstack)

Method Detail

getTarget

public Throwable getTarget()

inNativeCode

public boolean inNativeCode()
Return true if the TargetError was generated from native code. e.g. if the script called into a compiled java class which threw the excpetion. We distinguish so that we can print the stack trace for the native code case... the stack trace would not be useful if the exception was generated by the script. e.g. if the script explicitly threw an exception... (the stack trace would simply point to the bsh internals which generated the exception).

printStackTrace

public void printStackTrace()

printStackTrace

public void printStackTrace(PrintStream out)

printStackTrace

public void printStackTrace(boolean debug, PrintStream out)

printTargetError

public String printTargetError(Throwable t)
Generate a printable string showing the wrapped target exception. If the proxy mechanism is available, allow the extended print to check for UndeclaredThrowableException and print that embedded error.

toString

public String toString()

xPrintTargetError

public String xPrintTargetError(Throwable t)
Extended form of print target error. This indirection is used to print UndeclaredThrowableExceptions which are possible when the proxy mechanism is available. We are shielded from compile problems by using a bsh script. This is acceptable here because we're not in a critical path... Otherwise we'd need yet another dynamically loaded module just for this.
B) 2000 pat@pat.net :-)