|
2.17.2: 2011-06-17 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.basedb.util.error.ClassMapErrorHandler
public class ClassMapErrorHandler
Error handler that allows the registration of one or more
error handler for subclasses to Throwable
.
Use the addErrorHandler(Class, ErrorHandler)
to register
error handlers for specific exceptions. When the handleError(Throwable)
is invoked it checks the class of the throwable and looks for error handlers
for that class. If it can't find an error handler it will check the superclass
and so on. If no error handler is found the orginal error is re-thrown.
Field Summary | |
---|---|
private ErrorHandler |
defaultErrorHandler
|
private Map<Class<? extends Throwable>,List<ErrorHandler>> |
errorHandlers
Map of registered error handlers. |
Constructor Summary | |
---|---|
ClassMapErrorHandler(ErrorHandler defaultErrorHandler)
Create a new ClassMapErrorHandler . |
Method Summary | |
---|---|
void |
addErrorHandler(Class<? extends Throwable> t,
ErrorHandler handler)
Add an error handler for throwable:s of a specific class. |
boolean |
handleError(Throwable t)
Handle an error. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private Map<Class<? extends Throwable>,List<ErrorHandler>> errorHandlers
private final ErrorHandler defaultErrorHandler
Constructor Detail |
---|
public ClassMapErrorHandler(ErrorHandler defaultErrorHandler)
ClassMapErrorHandler
.
defaultErrorHandler
- The default error handler to use if no
other error handler is found, if null the error is re-thrownMethod Detail |
---|
public void addErrorHandler(Class<? extends Throwable> t, ErrorHandler handler)
t
- The class of throwable:s the error handler should handlehandler
- The error handlerpublic boolean handleError(Throwable t) throws Throwable
ErrorHandler
true
should be returned. If false
is returned
it indicates that this error handled doesn't know how to handle the
error. The caller should try another error handler or throw an exception.
handleError
in interface ErrorHandler
t
- The error to handle
Throwable
- If the error is final and can't be solved
|
2.17.2: 2011-06-17 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |