public class IonException extends RuntimeException
IOException
) are not
propagated directly but are instead wrapped in one or more
IonException
s.
This library does not promise that such an "external cause" will be the
direct cause
of the thrown exception: there
there may be a chain of multiple IonException
before getting to the
external cause. Here's an example of how to deal with this in a situation
where the caller wants to propagate IOException
s:
try { // Call some API } catch (IonException e) { IOException io = e.causeOfType(IOException.class); if (io != null) throw io; throw e; }
Constructor and Description |
---|
IonException() |
IonException(String message) |
IonException(String message,
Throwable cause) |
IonException(Throwable cause)
Constructs a new exception with the given cause, copying the message
from the cause into this instance.
|
Modifier and Type | Method and Description |
---|---|
<T extends Throwable> |
causeOfType(Class<T> type)
Finds the first exception in the
Throwable.getCause() chain that is
an instance of the given type. |
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
public IonException()
public IonException(String message)
public IonException(Throwable cause)
cause
- the root cause of the exception; must not be null.public <T extends Throwable> T causeOfType(Class<T> type)
Throwable.getCause()
chain that is
an instance of the given type.