Package com.google.gwt.core.client

## Class JavaScriptException

- java.lang.Object
- - java.lang.Throwable
  - - java.lang.Exception
    - - java.lang.RuntimeException
      - - com.google.gwt.core.client.impl.JavaScriptExceptionBase
        - - com.google.gwt.core.client.JavaScriptException

- All Implemented Interfaces:
    `java.io.Serializable`

      public final class JavaScriptException
      extends com.google.gwt.core.client.impl.JavaScriptExceptionBase

  Any JavaScript exceptions occurring within JSNI methods are wrapped as this class when caught in Java code. The wrapping does not occur until the exception passes out of JSNI into Java. Before that, the thrown object remains a native JavaScript exception object, and can be caught in JSNI as normal.

  The return value of `Throwable.getStackTrace()` may vary between browsers due to variations in the underlying error-reporting capabilities. When possible, the stack trace will be the stack trace of the underlying error object. If it is not possible to accurately report a stack trace, a zero-length array will be returned. In those cases where the underlying stack trace cannot be determined, `Throwable.fillInStackTrace()` can be called in the associated catch block to create a stack trace corresponding to the location where the JavaScriptException object was created.

       try {
         nativeMethod();
       } catch (JavaScriptException e) {
         if (e.getStackTrace().length == 0) {
           e.fillInStackTrace();
         }
       }

  See Also:
    Serialized Form

- - ### Constructor Summary

    Constructors
    Modifier | Constructor | Description
    --- | --- | ---
    `` | `JavaScriptException​(java.lang.Object e)` |
    `` | `JavaScriptException​(java.lang.Object e, java.lang.String description)` |
    `protected` | `JavaScriptException​(java.lang.String message)` | Used for testing instantiations.
    `` | `JavaScriptException​(java.lang.String name, java.lang.String description)` |

  - ### Method Summary

    All Methods Instance Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `java.lang.String` | `getDescription()` | Returns the original JavaScript message of the exception; may be `null`.
    `JavaScriptObject` | `getException()` | Deprecated. deprecated in favor for `getThrown()` and `isThrownSet()`
    `java.lang.String` | `getMessage()` |
    `java.lang.String` | `getName()` | Returns the original JavaScript type name of the exception; may be `null`.
    `java.lang.Object` | `getThrown()` | Returns the original thrown object from javascript; may be `null`.
    `boolean` | `isThrownSet()` | Returns `true` if a thrown object is not set for the exception.

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

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

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

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

- - ### Constructor Detail

    - #### JavaScriptException

          public JavaScriptException​(java.lang.Object e)

      Parameters:
        `e` - the object caught in JavaScript that triggered the exception

    - #### JavaScriptException

          public JavaScriptException​(java.lang.Object e,
                                     java.lang.String description)

      Parameters:
        `e` - the object caught in JavaScript that triggered the exception
        `description` - to include in getMessage(), e.g. at the top of a stack trace

    - #### JavaScriptException

          public JavaScriptException​(java.lang.String name,
                                     java.lang.String description)

    - #### JavaScriptException

          protected JavaScriptException​(java.lang.String message)

      Used for testing instantiations.
      Parameters:
        `message` - the detail message

  - ### Method Detail

    - #### isThrownSet

          public boolean isThrownSet()

      Returns `true` if a thrown object is not set for the exception.

    - #### getThrown

          public java.lang.Object getThrown()

      Returns the original thrown object from javascript; may be `null`.

    - #### getDescription

          public java.lang.String getDescription()

      Returns the original JavaScript message of the exception; may be `null`.

    - #### getException

          @Deprecated
          public JavaScriptObject getException()

      Deprecated.
      deprecated in favor for `getThrown()` and `isThrownSet()`
      Returns the original JavaScript the exception; may be `null`.

    - #### getMessage

          public java.lang.String getMessage()

      Overrides:
        `getMessage` in class `java.lang.Throwable`

    - #### getName

          public java.lang.String getName()

      Returns the original JavaScript type name of the exception; may be `null`.