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

Code
Comments
Other
Rev Date Author Line
2751 20 Oct 06 nicklas 1 /**
2751 20 Oct 06 nicklas 2   $Id$
2751 20 Oct 06 nicklas 3
3675 16 Aug 07 jari 4   Copyright (C) 2006 Nicklas Nordborg
2751 20 Oct 06 nicklas 5
2751 20 Oct 06 nicklas 6   This file is part of BASE - BioArray Software Environment.
2751 20 Oct 06 nicklas 7   Available at http://base.thep.lu.se/
2751 20 Oct 06 nicklas 8
2751 20 Oct 06 nicklas 9   BASE is free software; you can redistribute it and/or
2751 20 Oct 06 nicklas 10   modify it under the terms of the GNU General Public License
4479 05 Sep 08 jari 11   as published by the Free Software Foundation; either version 3
2751 20 Oct 06 nicklas 12   of the License, or (at your option) any later version.
2751 20 Oct 06 nicklas 13
2751 20 Oct 06 nicklas 14   BASE is distributed in the hope that it will be useful,
2751 20 Oct 06 nicklas 15   but WITHOUT ANY WARRANTY; without even the implied warranty of
2751 20 Oct 06 nicklas 16   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
2751 20 Oct 06 nicklas 17   GNU General Public License for more details.
2751 20 Oct 06 nicklas 18
2751 20 Oct 06 nicklas 19   You should have received a copy of the GNU General Public License
4515 11 Sep 08 jari 20   along with BASE. If not, see <http://www.gnu.org/licenses/>.
2751 20 Oct 06 nicklas 21 */
2751 20 Oct 06 nicklas 22 package net.sf.basedb.util.error;
2751 20 Oct 06 nicklas 23
2751 20 Oct 06 nicklas 24 /**
2751 20 Oct 06 nicklas 25    An interface to make it easier to implement dynamic error handling. 
2751 20 Oct 06 nicklas 26    A typical implementation allows the registration of one or more error
2751 20 Oct 06 nicklas 27    handlers. When an exception is thrown the {@link #handleError(Throwable)}
2751 20 Oct 06 nicklas 28    method is invoked on the first error handler. There are three outcomes:
2751 20 Oct 06 nicklas 29    <ul>
2751 20 Oct 06 nicklas 30    <li>The error handler has decided that the error is unrecoverable and
2751 20 Oct 06 nicklas 31      re-throws the same (or another) exception.
2751 20 Oct 06 nicklas 32    <li>The error handler could handle the error and returns TRUE to indicate
2751 20 Oct 06 nicklas 33      that processing should continue. No more error handlers should be invoked.
2751 20 Oct 06 nicklas 34    <li>The error handler doesn't know what to do and returns FALSE. The next error
2751 20 Oct 06 nicklas 35      handler should be invoked and if no more are available the exception
2751 20 Oct 06 nicklas 36      should be rethrown.
2751 20 Oct 06 nicklas 37    </ul>
2751 20 Oct 06 nicklas 38
2751 20 Oct 06 nicklas 39   @author nicklas
2751 20 Oct 06 nicklas 40   @version 2.0
2751 20 Oct 06 nicklas 41   @base.modified $Date$
2751 20 Oct 06 nicklas 42 */
2751 20 Oct 06 nicklas 43 public interface ErrorHandler
2751 20 Oct 06 nicklas 44 {
2751 20 Oct 06 nicklas 45
2751 20 Oct 06 nicklas 46   /**
2751 20 Oct 06 nicklas 47     Handle an error. If it is decided that the error is a final error
2751 20 Oct 06 nicklas 48     this method should rethrow the same or a different exception. If
2751 20 Oct 06 nicklas 49     if is decided that it is possible to continue with the current operation
2751 20 Oct 06 nicklas 50     <code>true</code> should be returned. If <code>false</code> is returned
2751 20 Oct 06 nicklas 51     it indicates that this error handled doesn't know how to handle the 
2751 20 Oct 06 nicklas 52     error. The caller should try another error handler or throw an exception.
2751 20 Oct 06 nicklas 53     
2751 20 Oct 06 nicklas 54     @param t The error to handle
2751 20 Oct 06 nicklas 55     @return TRUE if the error was handled successfully and the execution should
2751 20 Oct 06 nicklas 56       continue with the next item
2751 20 Oct 06 nicklas 57     @throws Throwable If the error is final and can't be solved
2751 20 Oct 06 nicklas 58   */
2751 20 Oct 06 nicklas 59   public boolean handleError(Throwable t)
2751 20 Oct 06 nicklas 60     throws Throwable;
2751 20 Oct 06 nicklas 61   
2751 20 Oct 06 nicklas 62 }