Class DefaultRequestExceptionHandler
- java.lang.Object
-
- org.apache.tapestry5.internal.services.DefaultRequestExceptionHandler
-
- All Implemented Interfaces:
RequestExceptionHandler
public class DefaultRequestExceptionHandler extends Object implements RequestExceptionHandler
Default implementation ofRequestExceptionHandler
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 (seeOperationException
andComponentEventException
). Configurations are flexible. You can either contribute aExceptionHandlerAssistant
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 implementContextAwareException
interface. If no configured exception type is found, the default exception pageSymbolConstants.EXCEPTION_REPORT_PAGE
is rendered. This fallback exception page must implement theExceptionReporter
interface.
-
-
Constructor Summary
Constructors Constructor Description DefaultRequestExceptionHandler(RequestPageCache pageCache, PageResponseRenderer renderer, org.slf4j.Logger logger, String pageName, Request request, Response response, ComponentClassResolver componentClassResolver, LinkSource linkSource, ServiceResources serviceResources, ExceptionReporter exceptionReporter, Map<Class,Object> configuration)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected 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 Detail
-
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, 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 Detail
-
handleRequestException
public void handleRequestException(Throwable exception) throws IOException
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
protected 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
- Parameters:
exception
- The exception that the context is formed for- Returns:
- Returns an array of objects to be used as the exception context
-
-