Class DefaultRequestExceptionHandler
java.lang.Object
org.apache.tapestry5.internal.services.DefaultRequestExceptionHandler
- All Implemented Interfaces:
RequestExceptionHandler
Default implementation of
RequestExceptionHandler
that displays the standard ExceptionReport page. Similarly to the
servlet spec's standard error handling, the default exception handler allows configuring handlers for specific types of
exceptions. The error-page/exception-type configuration in web.xml does not work in Tapestry application as errors are
wrapped in Tapestry's exception types (see OperationException
and ComponentEventException
).
Configurations are flexible. You can either contribute a ExceptionHandlerAssistant
to use arbitrary complex logic
for error handling or a page class to render for the specific exception. Additionally, exceptions can carry context for the
error page. Exception context is formed either from the name of Exception (e.g. SmtpNotRespondingException ->
ServiceFailure mapping
would render a page with URL /servicefailure/smtpnotresponding) or they can implement ContextAwareException
interface.
If no configured exception type is found, the default exception page SymbolConstants.EXCEPTION_REPORT_PAGE
is rendered.
This fallback exception page must implement the ExceptionReporter
interface.-
Constructor Summary
ConstructorsConstructorDescriptionDefaultRequestExceptionHandler
(RequestPageCache pageCache, PageResponseRenderer renderer, org.slf4j.Logger logger, String pageName, Request request, Response response, ComponentClassResolver componentClassResolver, LinkSource linkSource, ServiceResources serviceResources, ExceptionReporter exceptionReporter, boolean productionMode, Map<Class, Object> configuration) -
Method Summary
Modifier and TypeMethodDescriptionprotected Object[]
formExceptionContext
(Throwable exception) Form exception context either from the name of the exception, or the context the exception contains if it's of typeContextAwareException
void
handleRequestException
(Throwable exception) Handles the exception thrown at some point the request was being processed First checks if there was a specific exception handler/page configured for this exception type, it's super class or super-super class.
-
Constructor Details
-
DefaultRequestExceptionHandler
public DefaultRequestExceptionHandler(RequestPageCache pageCache, PageResponseRenderer renderer, org.slf4j.Logger logger, @Symbol("tapestry.exception-report-page") String pageName, Request request, Response response, ComponentClassResolver componentClassResolver, LinkSource linkSource, ServiceResources serviceResources, ExceptionReporter exceptionReporter, @Symbol("tapestry.production-mode") boolean productionMode, Map<Class, Object> configuration) - Parameters:
configuration
- A map of Exception class and handler values. A handler is either a page class or an ExceptionHandlerAssistant. ExceptionHandlerAssistant can be a class
-
-
Method Details
-
handleRequestException
Handles the exception thrown at some point the request was being processed First checks if there was a specific exception handler/page configured for this exception type, it's super class or super-super class. Renders the default exception page if none was configured.- Specified by:
handleRequestException
in interfaceRequestExceptionHandler
- Parameters:
exception
- The exception that was thrown- Throws:
IOException
-
formExceptionContext
Form exception context either from the name of the exception, or the context the exception contains if it's of typeContextAwareException
- Parameters:
exception
- The exception that the context is formed for- Returns:
- Returns an array of objects to be used as the exception context
-