bsh
Class TargetError

java.lang.Object
  |
  +--java.lang.Throwable
        |
        +--java.lang.Exception
              |
              +--bsh.EvalError
                    |
                    +--bsh.TargetError
All Implemented Interfaces:
java.io.Serializable

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.

See Also:
Serialized Form

Field Summary
 java.util.List arguments
           
 java.lang.String className
           
 int endColumn
           
 int endLine
           
(package private)  boolean inNativeCode
           
 java.lang.String methodName
           
 int startColumn
           
 int startLine
           
(package private)  java.lang.Throwable target
           
 java.lang.String tokenName
           
 java.lang.String warnUserMessage
           
 
Fields inherited from class bsh.EvalError
message, node
 
Fields inherited from class java.lang.Exception
 
Fields inherited from class java.lang.Throwable
 
Constructor Summary
TargetError(java.lang.String s, java.lang.Throwable t)
          If you're going to use this please catch and re-throw the exception in an AST and add the node...
TargetError(java.lang.String msg, java.lang.Throwable t, SimpleNode node, boolean inNativeCode)
           
TargetError(java.lang.Throwable t, SimpleNode node)
           
 
Method Summary
 java.lang.Throwable getTarget()
           
 boolean inNativeCode()
          Return true if the TargetError was generated from native code.
 void printStackTrace()
           
 void printStackTrace(boolean debug, java.io.PrintStream out)
           
 void printStackTrace(java.io.PrintStream out)
           
 java.lang.String printTargetError(java.lang.Throwable t)
          Generate a printable string showing the wrapped target exception.
 java.lang.String toString()
           
 java.lang.String xPrintTargetError(java.lang.Throwable t)
          Extended form of print target error.
 
Methods inherited from class bsh.EvalError
addNode, getErrorLineNumber, getErrorSourceFile, getErrorText, getMessage, getNode, prependMessage, reThrow, reThrow, reThrow, setMessage, setNode
 
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, initCause, printStackTrace, setStackTrace
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

startLine

public int startLine

endLine

public int endLine

startColumn

public int startColumn

endColumn

public int endColumn

tokenName

public java.lang.String tokenName

className

public java.lang.String className

methodName

public java.lang.String methodName

arguments

public java.util.List arguments

warnUserMessage

public java.lang.String warnUserMessage

target

java.lang.Throwable target

inNativeCode

boolean inNativeCode
Constructor Detail

TargetError

public TargetError(java.lang.String msg,
                   java.lang.Throwable t,
                   SimpleNode node,
                   boolean inNativeCode)

TargetError

public TargetError(java.lang.Throwable t,
                   SimpleNode node)

TargetError

public TargetError(java.lang.String s,
                   java.lang.Throwable t)
If you're going to use this please catch and re-throw the exception in an AST and add the node...

See Also:
EvalError.reThrow( SimpleNode )
Method Detail

getTarget

public java.lang.Throwable getTarget()

toString

public java.lang.String toString()
Overrides:
toString in class EvalError

printStackTrace

public void printStackTrace()
Overrides:
printStackTrace in class java.lang.Throwable

printStackTrace

public void printStackTrace(java.io.PrintStream out)
Overrides:
printStackTrace in class java.lang.Throwable

printStackTrace

public void printStackTrace(boolean debug,
                            java.io.PrintStream out)

printTargetError

public java.lang.String printTargetError(java.lang.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.


xPrintTargetError

public java.lang.String xPrintTargetError(java.lang.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.


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).