Top Description Fields Constructors Methods
com.amazon.ion

public Class IonException

extends RuntimeException
Class Inheritance
Known Direct Subclasses
com.amazon.ion.NullValueException, com.amazon.ion.OversizedValueException, com.amazon.ion.ReadOnlyValueException, com.amazon.ion.SubstituteSymbolTableException, com.amazon.ion.UnexpectedEofException, com.amazon.ion.UnknownSymbolException, com.amazon.ion.UnsupportedIonVersionException, com.amazon.ion.impl.BlockedBuffer.BlockedBufferException, com.amazon.ion.impl.IonReaderTextRawTokensX.IonReaderTextTokenException, com.amazon.ion.impl.IonReaderTextRawX.IonReaderTextParsingException, com.amazon.ion.impl.IonUTF8.InvalidUnicodeCodePoint, com.amazon.ion.impl._Private_ScalarConversions.ConversionException, com.amazon.ion.ContainedValueException, com.amazon.ion.EmptySymbolException, com.amazon.ion.InvalidSystemSymbolException
Imports
java.io.IOException, java.util.IdentityHashMap

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;
    }

Field Summary

Modifier and TypeField and Description
private static final long

Constructor Summary

AccessConstructor and Description
public
public
public
IonException(String message, Throwable cause)

public
IonException(Throwable
the root cause of the exception; must not be null.
cause
)

Constructs a new exception with the given cause, copying the message from the cause into this instance.

Method Summary

Modifier and TypeMethod and Description
public <T extends Throwable> T

Returns:

null if there's no cause of the given type.
causeOfType
(Class<T> type)

Finds the first exception in the getCause() chain that is an instance of the given type.

pack-priv Throwable

Returns:

null if there's no cause that's not an IonException.
externalCause
()

Finds the first exception in the getCause() chain that's not an IonException.

private <T extends Throwable> void
rethrowCauseOfType(Class<T> type)

Rethrows the first exception in the getCause() chain that is an instance of the given type.

Field Detail

serialVersionUIDback to summary
private static final long serialVersionUID

Hides java.lang.RuntimeException.serialVersionUID.

Constructor Detail

IonExceptionback to summary
public IonException()
IonExceptionback to summary
public IonException(String message)
IonExceptionback to summary
public IonException(String message, Throwable cause)
IonExceptionback to summary
public IonException(Throwable cause)

Constructs a new exception with the given cause, copying the message from the cause into this instance.

Parameters
cause:Throwable

the root cause of the exception; must not be null.

Method Detail

causeOfTypeback to summary
public <T extends Throwable> T causeOfType(Class<T> type)

Finds the first exception in the getCause() chain that is an instance of the given type.

Returns:T

null if there's no cause of the given type.

Annotations
@SuppressWarnings:unchecked
externalCauseback to summary
pack-priv Throwable externalCause()

Finds the first exception in the getCause() chain that's not an IonException.

Returns:Throwable

null if there's no cause that's not an IonException.

rethrowCauseOfTypeback to summary
private <T extends Throwable> void rethrowCauseOfType(Class<T> type) throws Throwable

Rethrows the first exception in the getCause() chain that is an instance of the given type. If no such cause is found, returns normally. FIXME Doesn't work under Java 5

Annotations
@SuppressWarnings:unused