001 /*
002 * Copyright 2013 Erik Kuefler
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
005 * in compliance with the License. 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 distributed under the License
010 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
011 * or implied. See the License for the specific language governing permissions and limitations under
012 * the License.
013 */
014 package com.ekuefler.supereventbus;
015
016 /**
017 * Marks an object as capable of handling exceptions thrown while dispatching events posted on the
018 * event bus. After all handlers have had a chance to handle an event, any exceptions thrown by
019 * handlers are collected, wrapped in an {@link EventBusException}, and passed in turn to all
020 * registered exception handlers.
021 *
022 * @author ekuefler@gmail.com (Erik Kuefler)
023 */
024 public interface ExceptionHandler {
025 /**
026 * Invoked whenever an exception occurs while handling an event, after all handlers have had a
027 * chance to handle the event. The underlying exception will be wrapped in an
028 * {@link EventBusException}, which provides access to the handler and event for which the
029 * exception occurred. If multiple exceptions occurred while dispatching an event, this method
030 * will be invoked multiple times.
031 *
032 * @param e a wrapper around the exception that occurred during event dispatch
033 */
034 void handleException(EventBusException e);
035 }