src/core/net/sf/basedb/util/extensions/ErrorHandler.java

Code
Comments
Other
Rev Date Author Line
5486 12 Nov 10 nicklas 1 /**
5486 12 Nov 10 nicklas 2   $Id$
5486 12 Nov 10 nicklas 3
5486 12 Nov 10 nicklas 4   Copyright (C) 2010 Nicklas Nordborg
5486 12 Nov 10 nicklas 5
5486 12 Nov 10 nicklas 6   This file is part of BASE - BioArray Software Environment.
5486 12 Nov 10 nicklas 7   Available at http://base.thep.lu.se/
5486 12 Nov 10 nicklas 8
5486 12 Nov 10 nicklas 9   BASE is free software; you can redistribute it and/or
5486 12 Nov 10 nicklas 10   modify it under the terms of the GNU General Public License
5486 12 Nov 10 nicklas 11   as published by the Free Software Foundation; either version 3
5486 12 Nov 10 nicklas 12   of the License, or (at your option) any later version.
5486 12 Nov 10 nicklas 13
5486 12 Nov 10 nicklas 14   BASE is distributed in the hope that it will be useful,
5486 12 Nov 10 nicklas 15   but WITHOUT ANY WARRANTY; without even the implied warranty of
5486 12 Nov 10 nicklas 16   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
5486 12 Nov 10 nicklas 17   GNU General Public License for more details.
5486 12 Nov 10 nicklas 18
5486 12 Nov 10 nicklas 19   You should have received a copy of the GNU General Public License
5486 12 Nov 10 nicklas 20   along with BASE. If not, see <http://www.gnu.org/licenses/>.
5486 12 Nov 10 nicklas 21 */
5486 12 Nov 10 nicklas 22 package net.sf.basedb.util.extensions;
5486 12 Nov 10 nicklas 23
5486 12 Nov 10 nicklas 24 /**
5486 12 Nov 10 nicklas 25   Error handlers are created by the factory for each request/use of 
5486 12 Nov 10 nicklas 26   an extension point. The error handler doesn't have to be thread-safe, but
5486 12 Nov 10 nicklas 27   must be if the factory re-uses a single instance. Whenever an exception
5486 12 Nov 10 nicklas 28   happens during the processing of an extension, the error is re-directed
5486 12 Nov 10 nicklas 29   to the error handler. The error handler is more or less free to do what
5486 12 Nov 10 nicklas 30   it wants. The default implementation {@link LoggingErrorHandlerFactory}
5486 12 Nov 10 nicklas 31   simply puts a message in the log. Note that it is not usually practical 
5486 12 Nov 10 nicklas 32   to let the error propagate up to the gui level.
5486 12 Nov 10 nicklas 33
5486 12 Nov 10 nicklas 34   @author Nicklas
5486 12 Nov 10 nicklas 35   @since 2.17
5486 12 Nov 10 nicklas 36   @base.modified $Date$
5486 12 Nov 10 nicklas 37 */
5486 12 Nov 10 nicklas 38 public interface ErrorHandler<A extends Action>
5486 12 Nov 10 nicklas 39 {
5486 12 Nov 10 nicklas 40   
5486 12 Nov 10 nicklas 41   /**
5486 12 Nov 10 nicklas 42     Handle an exception that has happened. It is up to
5486 12 Nov 10 nicklas 43     the error handler what should happen next. Typically,
5486 12 Nov 10 nicklas 44     error should always be logged but the error handler
5486 12 Nov 10 nicklas 45     may choose to re-throw the exception. If the exception
5486 12 Nov 10 nicklas 46     isn't already a runtime exception it must be wrapped.
5486 12 Nov 10 nicklas 47     
5486 12 Nov 10 nicklas 48     <p>
5486 12 Nov 10 nicklas 49     Note that there are three stages in the extension 
5486 12 Nov 10 nicklas 50     mechanism, which may cause some of the parameters to be null:
5486 12 Nov 10 nicklas 51     
5486 12 Nov 10 nicklas 52     <ul>
5486 12 Nov 10 nicklas 53     <li>Extension point intialization: Eg. when the render factory
5486 12 Nov 10 nicklas 54       is being prepared (context and action are both null)
5486 12 Nov 10 nicklas 55     <li>Extension intialization: Eg. when the action factory
5486 12 Nov 10 nicklas 56       is being prepared (action is null)
5486 12 Nov 10 nicklas 57     <li>Extension rendering: Eg. when rendering the actions of
5486 12 Nov 10 nicklas 58       a single extension (context and action are non-null)
5486 12 Nov 10 nicklas 59     </ul>
5486 12 Nov 10 nicklas 60     
5486 12 Nov 10 nicklas 61     @param context The extension context, which can be null
5486 12 Nov 10 nicklas 62     @param action The action that was being rendered when the
5486 12 Nov 10 nicklas 63       error happened, which can be null
5486 12 Nov 10 nicklas 64     @param message An optional error message
5486 12 Nov 10 nicklas 65     @param t The error
5486 12 Nov 10 nicklas 66   */
5486 12 Nov 10 nicklas 67   public void handleError(InvokationContext<? extends A> context, A action, 
5486 12 Nov 10 nicklas 68       String message, Throwable t);
5486 12 Nov 10 nicklas 69 }