Class UnhandledExceptionWriterInterceptor
java.lang.Object
com.opensymphony.xwork2.interceptor.AbstractInterceptor
name.matthewgreet.strutscommons.interceptor.UnhandledExceptionWriterInterceptor
- All Implemented Interfaces:
com.opensymphony.xwork2.interceptor.Interceptor
,Serializable
public class UnhandledExceptionWriterInterceptor
extends com.opensymphony.xwork2.interceptor.AbstractInterceptor
Detects an exception not handled by the form driven action, logs it, changes the result to 'input' or 'error' as
needed and, if it implements ValidationAware, writes an action error for the user. Checked exceptions are regarded
as an application rejection and use the 'input' result. Unchecked exceptions are regarded as system failures and use
the 'error' result.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
checkLogger
(com.opensymphony.xwork2.ActionInvocation invocation) Ensures the logger for this instance has been initialised.Returns error message for application exceptions.boolean
Returns whether changing result and logging when an exception is caught is disabled.boolean
Returns whether writing error message is disabled.protected org.apache.logging.log4j.Logger
Returns logger to be used for this instance;Returns error message for system failure exceptions.intercept
(com.opensymphony.xwork2.ActionInvocation invocation) protected boolean
Returns whether exception indicates a system failure, rather than rejection due to business rules.protected void
logException
(com.opensymphony.xwork2.ActionInvocation invocation, boolean isSystemFailure, Exception e) Called to log exception before diverting to new result.protected org.apache.logging.log4j.Logger
makeLogger
(com.opensymphony.xwork2.ActionInvocation invocation) Returns a new logger to be used by this interceptor instance.void
setApplicationErrorMessage
(String applicationErrorMessage) void
setDisabledChangeResult
(boolean disabledChangeResult) void
setDisabledErrorMessage
(boolean disabledErrorMessage) void
setSystemFailureErrorMessage
(String systemFailureErrorMessage) Methods inherited from class com.opensymphony.xwork2.interceptor.AbstractInterceptor
destroy, init
-
Constructor Details
-
UnhandledExceptionWriterInterceptor
public UnhandledExceptionWriterInterceptor()
-
-
Method Details
-
checkLogger
protected void checkLogger(com.opensymphony.xwork2.ActionInvocation invocation) Ensures the logger for this instance has been initialised. -
getLogger
protected org.apache.logging.log4j.Logger getLogger()Returns logger to be used for this instance; -
isSystemFailureException
Returns whether exception indicates a system failure, rather than rejection due to business rules. -
logException
protected void logException(com.opensymphony.xwork2.ActionInvocation invocation, boolean isSystemFailure, Exception e) Called to log exception before diverting to new result. -
makeLogger
protected org.apache.logging.log4j.Logger makeLogger(com.opensymphony.xwork2.ActionInvocation invocation) Returns a new logger to be used by this interceptor instance. -
intercept
- Specified by:
intercept
in interfacecom.opensymphony.xwork2.interceptor.Interceptor
- Specified by:
intercept
in classcom.opensymphony.xwork2.interceptor.AbstractInterceptor
- Throws:
Exception
-
getDisabledChangeResult
public boolean getDisabledChangeResult()Returns whether changing result and logging when an exception is caught is disabled. Defaults to false; -
setDisabledChangeResult
public void setDisabledChangeResult(boolean disabledChangeResult) -
getDisabledErrorMessage
public boolean getDisabledErrorMessage()Returns whether writing error message is disabled. Defaults to false. -
setDisabledErrorMessage
public void setDisabledErrorMessage(boolean disabledErrorMessage) -
getApplicationErrorMessage
Returns error message for application exceptions. May contain '${e}' as substitution field for exception's message. Defaults to "The action was rejected: ${e}". -
setApplicationErrorMessage
-
getSystemFailureErrorMessage
Returns error message for system failure exceptions. May contain '${e}' as substitution field for exception's message. Defaults to "A system failure occurred, which was logged". -
setSystemFailureErrorMessage
-