Package net.sf.basedb.util.extensions
Class RethrowErrorHandlerFactory
java.lang.Object
net.sf.basedb.util.extensions.LoggingErrorHandlerFactory
net.sf.basedb.util.extensions.RethrowErrorHandlerFactory
- All Implemented Interfaces:
ErrorHandler<Action>
,ErrorHandlerFactory<Action>
Extension to the logging error handler factory that create error handlers
that re-throw the original exception. If the exception is an instance of
RuntimeException it is re-thrown as is, otherwise it is wrapped inside
a new RuntimeException. This factory is it's own error handler and the
implementation is thread-safe.
- Since:
- 2.17
- Author:
- Nicklas
- Last modified
- $Date: 2014-04-09 14:21:20 +0200 (on, 09 apr 2014) $
-
Nested Class Summary
Nested classes/interfaces inherited from class net.sf.basedb.util.extensions.LoggingErrorHandlerFactory
LoggingErrorHandlerFactory.Level
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptiongetErrorHandler
(InvokationContext<? extends Action> context) Get an error handler for the current context.void
handleError
(InvokationContext<? extends Action> context, Action action, String message, Throwable t) Handle an exception that has happened.Methods inherited from class net.sf.basedb.util.extensions.LoggingErrorHandlerFactory
setLevel, setRememberLast
-
Field Details
-
log
-
-
Constructor Details
-
RethrowErrorHandlerFactory
public RethrowErrorHandlerFactory()
-
-
Method Details
-
getErrorHandler
Description copied from interface:ErrorHandlerFactory
Get an error handler for the current context. This method is called once for each request/use of an extension point. Errors that happen when processing things related to this extension point will be directed to the error handler returned by this method. The factory may create a new or it may re-use the same error handler for each request. If the error handler is re-used it must be thread-safe.- Specified by:
getErrorHandler
in interfaceErrorHandlerFactory<Action>
- Overrides:
getErrorHandler
in classLoggingErrorHandlerFactory
- Parameters:
context
- The current invokation context which is an extension point context (theInvokationContext.getExtension()
method is expected to return null)
-
handleError
public void handleError(InvokationContext<? extends Action> context, Action action, String message, Throwable t) Description copied from interface:ErrorHandler
Handle an exception that has happened. It is up to the error handler what should happen next. Typically, error should always be logged but the error handler may choose to re-throw the exception. If the exception isn't already a runtime exception it must be wrapped.Note that there are three stages in the extension mechanism, which may cause some of the parameters to be null:
- Extension point intialization: Eg. when the render factory is being prepared (context and action are both null)
- Extension intialization: Eg. when the action factory is being prepared (action is null)
- Extension rendering: Eg. when rendering the actions of a single extension (context and action are non-null)
- Specified by:
handleError
in interfaceErrorHandler<Action>
- Overrides:
handleError
in classLoggingErrorHandlerFactory
- Parameters:
context
- The extension context, which can be nullaction
- The action that was being rendered when the error happened, which can be nullmessage
- An optional error messaget
- The error
-