public class BackingStoreException extends RuntimeException
IOException or a SQLException as its cause.
This method provides a unwrapOrRethrow(Class) convenience method which can be used
for re-throwing the cause as in the example below. This allows client code to behave as if a
Collection interface was allowed to declare checked exceptions.
void myMethod() throws IOException {
Collection c = ...;
try {
c.doSomeStuff();
} catch (BackingStoreException e) {
throw e.unwrapOrRethrow(IOException.class);
}
}
java.io.UncheckedIOExceptionUncheckedIOException which partially overlaps
the purpose of this BackingStoreException. While Apache SIS still uses
BackingStoreException as a general mechanism for any kind of checked
exceptions, client code targeting JDK8 would be well advised to catch both kind
of exceptions for robustness.Defined in the sis-utility module
| Constructor and Description |
|---|
BackingStoreException()
Constructs a new exception with no detail message.
|
BackingStoreException(String message)
Constructs a new exception with the specified detail message.
|
BackingStoreException(String message,
Throwable cause)
Constructs a new exception with the specified detail message and cause.
|
BackingStoreException(Throwable cause)
Constructs a new exception with the specified cause.
|
| Modifier and Type | Method and Description |
|---|---|
<E extends Exception> |
unwrapOrRethrow(Class<E> type)
Returns the underlying cause as an exception of the given type,
or re-throw the exception.
|
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toStringpublic BackingStoreException()
public BackingStoreException(String message)
message - the detail message, saved for later retrieval by the Throwable.getMessage() method.public BackingStoreException(Throwable cause)
cause - the cause, saved for later retrieval by the Throwable.getCause() method.public BackingStoreException(String message, Throwable cause)
message - the detail message, saved for later retrieval by the Throwable.getMessage() method.cause - the cause, saved for later retrieval by the Throwable.getCause() method.public <E extends Exception> E unwrapOrRethrow(Class<E> type) throws RuntimeException, BackingStoreException
RuntimeException, throws that exception.this.void myMethod() throws IOException {
Collection c = ...;
try {
c.doSomeStuff();
} catch (BackingStoreException e) {
throw e.unwrapOrRethrow(IOException.class);
}
}E - the type of the exception to unwrap.type - the type of the exception to unwrap.null).RuntimeException - if the cause is an instance of RuntimeException,
in which case that instance is re-thrown.BackingStoreException - if the cause is neither the given type or an instance
of RuntimeException, in which case this exception is re-thrown.Copyright © 2010–2017 The Apache Software Foundation. All rights reserved.