    001    // Copyright 2008 The Apache Software Foundation
    002    //
    003    // Licensed under the Apache License, Version 2.0 (the "License");
    004    // you may not use this file except in compliance with the License.
    005    // You may obtain a copy of the License at
    006    //
    007    //     http://www.apache.org/licenses/LICENSE-2.0
    008    //
    009    // Unless required by applicable law or agreed to in writing, software
    010    // distributed under the License is distributed on an "AS IS" BASIS,
    011    // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    012    // See the License for the specific language governing permissions and
    013    // limitations under the License.
    014
    015    package org.apache.tapestry5.runtime;
    016
    017    import org.apache.tapestry5.EventContext;
    018    import org.apache.tapestry5.ioc.internal.util.TapestryException;
    019
    020    /**
    021     * A wrapper exception around any exception thrown when invoking a component event handler. In some cases, the
    022     * underlying exception may have been a declared exception, and will be wrapped in a RuntimeException.
    023     *
    024     * @see org.apache.tapestry5.ioc.util.ExceptionUtils#findCause(Throwable, Class)
    025     */
    026    public class ComponentEventException extends TapestryException
    027    {
    028        private final String eventType;
    029
    030        private final EventContext context;
    031
    032        /**
    033         * @param message   exception message
    034         * @param eventType type of event that triggered the exception
    035         * @param context   context passed with the failed event
    036         * @param location  location of the component while failed (may be null)
    037         * @param cause     underlying exception
    038         */
    039        public ComponentEventException(String message, String eventType, EventContext context, Object location,
    040                                       Throwable cause)
    041        {
    042            super(message, location, cause);
    043
    044            this.eventType = eventType;
    045            this.context = context;
    046        }
    047
    048        public String getEventType()
    049        {
    050            return eventType;
    051        }
    052
    053        public EventContext getContext()
    054        {
    055            return context;
    056        }
    057    }