|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.lang.Throwable
java.lang.Exception
java.io.IOException
org.apache.commons.io.IOExceptionWithCause
org.apache.commons.io.TaggedIOException
public class TaggedIOException
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.
| Constructor Summary | |
|---|---|
TaggedIOException(IOException original,
Serializable tag)
Creates a tagged wrapper for the given exception. |
|
| Method Summary | |
|---|---|
IOException |
getCause()
Returns the wrapped exception. |
Serializable |
getTag()
Returns the serializable tag object. |
static boolean |
isTaggedWith(Throwable throwable,
Object tag)
Checks whether the given throwable is tagged with the given tag. |
static void |
throwCauseIfTaggedWith(Throwable throwable,
Object tag)
Throws the original IOException if the given throwable is
a TaggedIOException decorator the given tag. |
| Methods inherited from class java.lang.Throwable |
|---|
fillInStackTrace, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public TaggedIOException(IOException original,
Serializable tag)
original - the exception to be taggedtag - tag of this exception| Method Detail |
|---|
public static boolean isTaggedWith(Throwable throwable,
Object 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 checktag - tag object
true if the throwable has the specified tag,
otherwise false
public static void throwCauseIfTaggedWith(Throwable throwable,
Object tag)
throws IOException
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 exceptiontag - tag object
IOException - original exception from the tagged decorator, if anypublic Serializable getTag()
public IOException getCause()
Throwable.getCause() method is the narrower return type.
getCause in class Throwable
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||