public final class ForeignException extends RuntimeException
Allows foreign exceptions to be caught in guest Java and provides seamless access to the message,
cause and a polyglot stacktrace containing all guest frames if any. ForeignException can
only catch and wrap foreign exceptions.
assert Interop.isException(foreignException);
try {
throw Interop.throwException(foreignException);
} catch (ForeignException e) {
log(e.getClass() + ": " + e.getMessage());
...
throw e;
}
The raw foreign exception object which can serve polyglot messages e.g.
InteropLibrary#isException(rawForeignException) can be retrieved with
ForeignException.getForeignExceptionObject().Interop.throwException(Object),
Serialized Form| Modifier and Type | Method and Description |
|---|---|
Throwable |
fillInStackTrace() |
Throwable |
getCause() |
Object |
getForeignExceptionObject()
Returns the original wrapped foreign exception.
|
String |
getMessage() |
Throwable |
initCause(Throwable cause) |
void |
setStackTrace(StackTraceElement[] stackTrace)
Unsupported,
ForeignException instances are by definition foreign and thus
stacktraces should not be controllable by the guest. |
addSuppressed, getLocalizedMessage, getStackTrace, getSuppressed, printStackTrace, printStackTrace, printStackTrace, toStringpublic Object getForeignExceptionObject()
Interop messages.public String getMessage()
getMessage in class Throwablepublic void setStackTrace(StackTraceElement[] stackTrace)
ForeignException instances are by definition foreign and thus
stacktraces should not be controllable by the guest.setStackTrace in class Throwablepublic Throwable fillInStackTrace()
fillInStackTrace in class Throwable