org.apache.tapestry5.internal.services

## Class DefaultRequestExceptionHandler

- java.lang.Object
- - org.apache.tapestry5.internal.services.DefaultRequestExceptionHandler

- All Implemented Interfaces:
    RequestExceptionHandler

      public class DefaultRequestExceptionHandler
      extends Object
      implements 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

    Constructors
    Constructor and 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 and 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 type `ContextAwareException`
    `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.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### DefaultRequestExceptionHandler

          public DefaultRequestExceptionHandler(RequestPageCache pageCache,
                                                PageResponseRenderer renderer,
                                                org.slf4j.Logger logger,
                                                @Symbol(value="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 interface `RequestExceptionHandler`
      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 type `ContextAwareException`
      Parameters:
        `exception` - The exception that the context is formed for
      Returns:
        Returns an array of objects to be used as the exception context

${project.version} - Copyright © 2003-2015 The Apache Software Foundation.