Package bsh
Class TargetError
- java.lang.Object
-
- java.lang.Throwable
-
- java.lang.Exception
-
- bsh.EvalError
-
- bsh.TargetError
-
- All Implemented Interfaces:
java.io.Serializable
public final 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.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description TargetError(java.lang.String msg, java.lang.Throwable t, bsh.SimpleNode node, CallStack callstack, boolean inNativeCode)TargetError(java.lang.Throwable t, bsh.SimpleNode node, CallStack callstack)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringgetMessage()Print the error with line number and stack trace.java.lang.ThrowablegetTarget()booleaninNativeCode()Return true if the TargetError was generated from native code.voidprintStackTrace()voidprintStackTrace(boolean debug, java.io.PrintStream out)voidprintStackTrace(java.io.PrintStream out)java.lang.StringtoString()-
Methods inherited from class bsh.EvalError
getErrorLineNumber, getErrorSourceFile, getErrorText, getRawMessage, getScriptStackTrace, reThrow
-
-
-
-
Method Detail
-
getTarget
public java.lang.Throwable getTarget()
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Throwable
-
getMessage
public java.lang.String getMessage()
Description copied from class:EvalErrorPrint the error with line number and stack trace.- Overrides:
getMessagein classEvalError
-
printStackTrace
public void printStackTrace()
- Overrides:
printStackTracein classjava.lang.Throwable
-
printStackTrace
public void printStackTrace(java.io.PrintStream out)
- Overrides:
printStackTracein classjava.lang.Throwable
-
printStackTrace
public void printStackTrace(boolean debug, java.io.PrintStream out)
-
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).
-
-