|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
ObjectThrowable
Exception
RuntimeException
BackingStoreException
public class BackingStoreException
Thrown to indicate that an operation could not complete because of a failure in the backing
store (a file or a database). This exception is thrown by collection implementations that are
not allowed to throw checked exceptions. This exception usually has an IOException or
a SQLException as its cause.
This method provides a unwrapOrRethrow(Class) convenience method which can be used
for rethrowing 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);
}
}
| utility/geotk-utility (download) | View source code for this class |
| Constructor Summary | |
|---|---|
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. |
|
| Method Summary | ||
|---|---|---|
|
unwrapOrRethrow(Class<E> type)
Returns the underlying cause as an exception of the given type, or rethrow the exception. |
|
| Methods inherited from class Throwable |
|---|
fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString |
| Methods inherited from class Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public 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.| Method Detail |
|---|
public <E extends Exception> E unwrapOrRethrow(Class<E> type)
throws RuntimeException,
BackingStoreException
RuntimeException, throws
that exception.this.This method should be used as in the example below:
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 rethrown.
BackingStoreException - if the cause is neither the given type or an instance
of RuntimeException, in which case this exception is rethrown.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||