Class JsRejectionException

All Implemented Interfaces:
Serializable

public class JsRejectionException extends RuntimeException
The carrier that takes a JS promise rejection across the Java boundary, and the only exception type the engine ever unwraps back into a JS reason. JsPromise.toFuture() completes exceptionally with one of these, so a Java consumer sees it per CompletableFuture norms — usually nested inside a CompletionException or ExecutionException.

Coming the other way, an arbitrary Java exception never masquerades as a JS rejection: a stage that failed with something else is converted by the same host-error rules a catch clause applies, and host cancellation (EngineInterruptedException) is re-thrown rather than turned into a catchable reason.

See Also:
  • Constructor Details

    • JsRejectionException

      public JsRejectionException(Object reason)
  • Method Details

    • getReason

      public Object getReason()
      The exact JS value the promise was rejected with — an Error object in the common case, but JS can reject with anything.