TargetError (jEdit API Documentation)
Date: 2015-02-03

org.gjt.sp.jedit.bsh

## Class TargetError

- java.lang.Object
- - java.lang.Throwable
  - - java.lang.Exception
    - - org.gjt.sp.jedit.bsh.EvalError
      - - org.gjt.sp.jedit.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

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `TargetError(java.lang.String msg, java.lang.Throwable t, org.gjt.sp.jedit.bsh.SimpleNode node, CallStack callstack, boolean inNativeCode)`
    `TargetError(java.lang.Throwable t, org.gjt.sp.jedit.bsh.SimpleNode node, CallStack callstack)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `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()` Print the error with line number and stack trace.
    `java.lang.String` | `xPrintTargetError(java.lang.Throwable t)` Extended form of print target error.

    - ### Methods inherited from class org.gjt.sp.jedit.bsh.EvalError

      `getErrorLineNumber, getErrorSourceFile, getErrorText, getMessage, getScriptStackTrace, prependMessage, reThrow, setMessage`

    - ### Methods inherited from class java.lang.Throwable

      `addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, getSuppressed, initCause, printStackTrace, setStackTrace`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### TargetError

          public TargetError(java.lang.String msg,
                     java.lang.Throwable t,
                     org.gjt.sp.jedit.bsh.SimpleNode node,
                     CallStack callstack,
                     boolean inNativeCode)

    - #### TargetError

          public TargetError(java.lang.Throwable t,
                     org.gjt.sp.jedit.bsh.SimpleNode node,
                     CallStack callstack)

  - ### Method Detail

    - #### getTarget

          public java.lang.Throwable getTarget()

    - #### toString

          public java.lang.String toString()

      Description copied from class: `EvalError`
      Print the error with line number and stack trace.
      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).