src/core/net/sf/basedb/util/error/SimpleErrorHandler.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    A simple error handler that either ignores all errors or
2751 20 Oct 06 nicklas 26    re-throws them.
2751 20 Oct 06 nicklas 27    
2751 20 Oct 06 nicklas 28   @author nicklas
2751 20 Oct 06 nicklas 29   @version 2.0
2751 20 Oct 06 nicklas 30   @base.modified $Date$
2751 20 Oct 06 nicklas 31 */
2751 20 Oct 06 nicklas 32 public class SimpleErrorHandler
2751 20 Oct 06 nicklas 33   implements ErrorHandler
2751 20 Oct 06 nicklas 34 {
2751 20 Oct 06 nicklas 35
2751 20 Oct 06 nicklas 36   private final boolean ignoreAllErrors;
2751 20 Oct 06 nicklas 37   
2751 20 Oct 06 nicklas 38   /**
2751 20 Oct 06 nicklas 39     Create a new simple error handler.
2751 20 Oct 06 nicklas 40     @param ignoreAllErrors TRUE to ignore all errors, FALSE to re-throw them
2751 20 Oct 06 nicklas 41   */
2751 20 Oct 06 nicklas 42   public SimpleErrorHandler(boolean ignoreAllErrors)
2751 20 Oct 06 nicklas 43   {
2751 20 Oct 06 nicklas 44     this.ignoreAllErrors = ignoreAllErrors;
2751 20 Oct 06 nicklas 45   }
2751 20 Oct 06 nicklas 46   
2751 20 Oct 06 nicklas 47   /*
2751 20 Oct 06 nicklas 48     From the ErrorHandler interface
2751 20 Oct 06 nicklas 49     -------------------------------------------
2751 20 Oct 06 nicklas 50   */
2751 20 Oct 06 nicklas 51   /**
2751 20 Oct 06 nicklas 52     Return TRUE if all errors should be ignored, otherwise re-throw the
2751 20 Oct 06 nicklas 53     throwable.
2751 20 Oct 06 nicklas 54   */
6127 14 Sep 12 nicklas 55   @Override
2751 20 Oct 06 nicklas 56   public boolean handleError(Throwable t) 
2751 20 Oct 06 nicklas 57     throws Throwable
2751 20 Oct 06 nicklas 58   {
2751 20 Oct 06 nicklas 59     if (ignoreAllErrors) return true;
2751 20 Oct 06 nicklas 60     throw t;
2751 20 Oct 06 nicklas 61   }
2751 20 Oct 06 nicklas 62   // -------------------------------------------
2751 20 Oct 06 nicklas 63
2751 20 Oct 06 nicklas 64 }