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;
014
015import org.apache.tapestry5.http.Link;
016import org.apache.tapestry5.services.RequestExceptionHandler;
017
018import java.io.IOException;
019import java.util.List;
020
021/**
022 * A contribution to the default {@link RequestExceptionHandler} service, this is mapped to an exception class,
023 * allowing class specific (based on an inheritance search) handling of an exception.
024 *
025 * @see ContextAwareException
026 */
027public interface ExceptionHandlerAssistant
028{
029    /**
030     * Handles the exception, returning a page class or link to redirect to.
031     *
032     * @param exception
033     *         the exception as thrown
034     * @param exceptionContext
035     *         a page activation context that is derived from the root-most exception
036     * @return either a page class or a {@link Link}; a page will be redirected to, with the exception context
037     * as the page activation context
038     * @throws IOException
039     */
040    Object handleRequestException(Throwable exception, List<Object> exceptionContext) throws IOException;
041}