    001// Licensed under the Apache License, Version 2.0 (the "License");
    002// you may not use this file except in compliance with the License.
    003// You may obtain a copy of the License at
    004//
    005//     http://www.apache.org/licenses/LICENSE-2.0
    006//
    007// Unless required by applicable law or agreed to in writing, software
    008// distributed under the License is distributed on an "AS IS" BASIS,
    009// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    010// See the License for the specific language governing permissions and
    011// limitations under the License.
    012
    013package org.apache.tapestry5.services;
    014
    015import org.apache.tapestry5.ExceptionHandlerAssistant;
    016import org.apache.tapestry5.ioc.annotations.UsesMappedConfiguration;
    017
    018import java.io.IOException;
    019
    020/**
    021 * Service invoked when an uncaught exception occurs. The error handler is responsible for providing a response to the
    022 * user to describe the error.
    023 *
    024 * The default implementation accepts the configuration, which maps an exception class to a corresponding helper.
    025 * The helper is either an instance of {@link ExceptionHandlerAssistant} or is a Class for a page that will be redirected
    026 * to, to present the exception.
    027 */
    028@UsesMappedConfiguration(key = Class.class, value = Object.class)
    029public interface RequestExceptionHandler
    030{
    031    /**
    032     * Responsible for handling the error <em>in some way</em> and providing <em>some response</em> to the client. A
    033     * default implementation may render an error response page.
    034     *
    035     *
    036     * The handler is also responsible for setting the response status and the X-Tapestry-ErrorMessage response header.
    037     * These are very important in Ajax requests to allow the client-side logic to detect the error and present it to
    038     * the user.
    039     *
    040     * @param exception
    041     *         uncaught exception to be reported
    042     * @throws IOException
    043     */
    044    void handleRequestException(Throwable exception) throws IOException;
    045}