Class DebugException

All Implemented Interfaces:
Serializable

public final class DebugException extends RuntimeException
Information about an exception thrown from a guest language. This exception does not contain a Java stack trace, use getDebugStackTrace() to find out the guest language stack trace.

Debugger methods that run guest language code may throw this exception.

Since:
19.0
See Also:
  • Method Details

    • fillInStackTrace

      public Throwable fillInStackTrace()
      Unsupported, DebugException instances are not writable therefore filling the stack trace has no effect for them.
      Overrides:
      fillInStackTrace in class Throwable
      Since:
      19.0
    • setStackTrace

      public void setStackTrace(StackTraceElement[] stackTrace)
      Unsupported, DebugException instances are not writable therefore setting the stack trace has no effect for them.
      Overrides:
      setStackTrace in class Throwable
      Since:
      19.0
    • getStackTrace

      public StackTraceElement[] getStackTrace()
      Gets stack trace elements of guest languages. It is recommended to use getDebugStackTrace() as the guest language stack elements do not always fit the Java format for stack trace elements.
      Overrides:
      getStackTrace in class Throwable
      Since:
      19.0
    • getDebugStackTrace

      public List<DebugStackTraceElement> getDebugStackTrace()
      Gets stack trace elements of guest languages.
      Since:
      19.0
    • getDebugAsynchronousStacks

      public List<List<DebugStackTraceElement>> getDebugAsynchronousStacks()
      Get a list of asynchronous stack traces that led to scheduling of the exception's execution. Returns an empty list if no asynchronous stack is known. The first asynchronous stack is at the first index in the list. A possible next asynchronous stack (that scheduled execution of the previous one) is at the next index in the list.

      Languages might not provide asynchronous stack traces by default for performance reasons. Call DebuggerSession.setAsynchronousStackDepth(int) to request asynchronous stacks. Languages may provide asynchronous stacks if it's of no performance penalty, or if requested by other options.

      Since:
      20.1.0
      See Also:
    • printStackTrace

      public void printStackTrace()
      Overrides:
      printStackTrace in class Throwable
      Since:
      19.0
    • printStackTrace

      public void printStackTrace(PrintStream s)
      Overrides:
      printStackTrace in class Throwable
      Since:
      19.0
    • printStackTrace

      public void printStackTrace(PrintWriter s)
      Overrides:
      printStackTrace in class Throwable
      Since:
      19.0
    • isInternalError

      public boolean isInternalError()
      Returns true if this exception indicates an internal error.
      Since:
      19.0
    • getExceptionObject

      public DebugValue getExceptionObject()
      Get a guest language object representing the exception, if any.
      Returns:
      an exception object, or null
      Since:
      19.0
    • getThrowLocation

      public SourceSection getThrowLocation()
      Get source code location where this exception was thrown from.
      Returns:
      the thrown location, or null when the thrown location is not known.
      Since:
      19.0
    • getCatchLocation

      public DebugException.CatchLocation getCatchLocation()
      Get source code location where this exception is to be caught. In case this exception is going to be caught by guest language code, the catch location is provided. null is returned for uncaught exceptions.
      Returns:
      the catch location, or null in case of uncaught exceptions.
      Since:
      19.0
    • getRawException

      public Throwable getRawException(Class<? extends TruffleLanguage<?>> languageClass)
      Returns the guest language representation of the exception, or null if the requesting language class does not match the root node language at the throw location. This method is permitted only if the guest language class is available. This is the case if you want to utilize the Debugger API directly from within a guest language, or if you are an instrument bound/dependent on a specific language.
      Parameters:
      languageClass - the Truffle language class for a given guest language
      Returns:
      the throwable guest language exception object
      Since:
      20.1