Class TaggedIOException

  • All Implemented Interfaces:

    public class TaggedIOExceptionextends IOExceptionWithCause
    An IOException decorator that adds a serializable tag to the wrapped exception. Both the tag and the original exception can be used to determine further processing when this exception is caught.
    See Also:
    Serialized Form
    • Constructor Detail

      • TaggedIOException

        public TaggedIOException(IOException original,                 Serializable tag)
        Creates a tagged wrapper for the given exception.
        original - the exception to be tagged
        tag - tag of this exception
    • Method Detail

      • isTaggedWith

        public static boolean isTaggedWith(Throwable throwable,                   Object tag)
        Checks whether the given throwable is tagged with the given tag.

        This check can only succeed if the throwable is a TaggedIOException and the tag is Serializable, but the argument types are intentionally more generic to make it easier to use this method without type casts.

        A typical use for this method is in a catch block to determine how a caught exception should be handled:

         Serializable tag = ...; try {     ...; } catch (Throwable t) {     if (TaggedIOExcepton.isTaggedWith(t, tag)) {         // special processing for tagged exception     } else {         // handling of other kinds of exceptions     } } 

        throwable - The Throwable object to check
        tag - tag object
        true if the throwable has the specified tag, otherwise false
      • throwCauseIfTaggedWith

        public static void throwCauseIfTaggedWith(Throwable throwable,                          Object tag)                                   throws IOException
        Throws the original IOException if the given throwable is a TaggedIOException decorator the given tag. Does nothing if the given throwable is of a different type or if it is tagged with some other tag.

        This method is typically used in a catch block to selectively rethrow tagged exceptions.

         Serializable tag = ...; try {     ...; } catch (Throwable t) {     TaggedIOExcepton.throwCauseIfTagged(t, tag);     // handle other kinds of exceptions } 

        throwable - an exception
        tag - tag object
        IOException - original exception from the tagged decorator, if any
      • getTag

        public Serializable getTag()
        Returns the serializable tag object.
        tag object

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

Add the Maven Dependecy to your project: maven dependecy for com.amazonaws : aws-java-sdk : 1.3.14