Package com.amazon.ion
Class IonException
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
com.amazon.ion.IonException
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
_Private_ScalarConversions.ConversionException,ContainedValueException,EmptySymbolException,InvalidSystemSymbolException,NullValueException,OversizedValueException,ReadOnlyValueException,SubstituteSymbolTableException,UnexpectedEofException,UnknownSymbolException,UnsupportedIonVersionException
Base class for exceptions thrown throughout this library. In most cases,
external exceptions (a common example being
IOException) are not
propagated directly but are instead wrapped in one or more
IonExceptions.
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 IOExceptions:
try {
// Call some API
}
catch (IonException e) {
IOException io = e.causeOfType(IOException.class);
if (io != null) throw io;
throw e;
}
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionIonException(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. -
Method Summary
Modifier and TypeMethodDescription<T extends Throwable>
TcauseOfType(Class<T> type) Finds the first exception in theThrowable.getCause()chain that is an instance of the given type.Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
Constructor Details
-
IonException
public IonException() -
IonException
-
IonException
-
IonException
Constructs a new exception with the given cause, copying the message from the cause into this instance.- Parameters:
cause- the root cause of the exception; must not be null.
-
-
Method Details
-
causeOfType
Finds the first exception in theThrowable.getCause()chain that is an instance of the given type.- Returns:
- null if there's no cause of the given type.
-