Class IonException

All Implemented Interfaces:
Serializable
Direct Known Subclasses:
_Private_ScalarConversions.ConversionException, ContainedValueException, EmptySymbolException, InvalidSystemSymbolException, NullValueException, OversizedValueException, ReadOnlyValueException, SubstituteSymbolTableException, UnexpectedEofException, UnknownSymbolException, UnsupportedIonVersionException

public class IonException extends RuntimeException
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 Details

    • IonException

      public IonException()
    • IonException

      public IonException(String message)
    • IonException

      public IonException(String message, Throwable cause)
    • IonException

      public IonException(Throwable cause)
      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

      public <T extends Throwable> T causeOfType(Class<T> type)
      Finds the first exception in the Throwable.getCause() chain that is an instance of the given type.
      Returns:
      null if there's no cause of the given type.