2751 |
20 Oct 06 |
nicklas |
1 |
/** |
2751 |
20 Oct 06 |
nicklas |
$Id$ |
2751 |
20 Oct 06 |
nicklas |
3 |
|
3675 |
16 Aug 07 |
jari |
Copyright (C) 2006 Nicklas Nordborg |
2751 |
20 Oct 06 |
nicklas |
5 |
|
2751 |
20 Oct 06 |
nicklas |
This file is part of BASE - BioArray Software Environment. |
2751 |
20 Oct 06 |
nicklas |
Available at http://base.thep.lu.se/ |
2751 |
20 Oct 06 |
nicklas |
8 |
|
2751 |
20 Oct 06 |
nicklas |
BASE is free software; you can redistribute it and/or |
2751 |
20 Oct 06 |
nicklas |
modify it under the terms of the GNU General Public License |
4479 |
05 Sep 08 |
jari |
as published by the Free Software Foundation; either version 3 |
2751 |
20 Oct 06 |
nicklas |
of the License, or (at your option) any later version. |
2751 |
20 Oct 06 |
nicklas |
13 |
|
2751 |
20 Oct 06 |
nicklas |
BASE is distributed in the hope that it will be useful, |
2751 |
20 Oct 06 |
nicklas |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
2751 |
20 Oct 06 |
nicklas |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2751 |
20 Oct 06 |
nicklas |
GNU General Public License for more details. |
2751 |
20 Oct 06 |
nicklas |
18 |
|
2751 |
20 Oct 06 |
nicklas |
You should have received a copy of the GNU General Public License |
4515 |
11 Sep 08 |
jari |
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 |
An interface to make it easier to implement dynamic error handling. |
2751 |
20 Oct 06 |
nicklas |
A typical implementation allows the registration of one or more error |
2751 |
20 Oct 06 |
nicklas |
handlers. When an exception is thrown the {@link #handleError(Throwable)} |
2751 |
20 Oct 06 |
nicklas |
method is invoked on the first error handler. There are three outcomes: |
2751 |
20 Oct 06 |
nicklas |
<ul> |
2751 |
20 Oct 06 |
nicklas |
<li>The error handler has decided that the error is unrecoverable and |
2751 |
20 Oct 06 |
nicklas |
re-throws the same (or another) exception. |
2751 |
20 Oct 06 |
nicklas |
<li>The error handler could handle the error and returns TRUE to indicate |
2751 |
20 Oct 06 |
nicklas |
that processing should continue. No more error handlers should be invoked. |
2751 |
20 Oct 06 |
nicklas |
<li>The error handler doesn't know what to do and returns FALSE. The next error |
2751 |
20 Oct 06 |
nicklas |
handler should be invoked and if no more are available the exception |
2751 |
20 Oct 06 |
nicklas |
should be rethrown. |
2751 |
20 Oct 06 |
nicklas |
</ul> |
2751 |
20 Oct 06 |
nicklas |
38 |
|
2751 |
20 Oct 06 |
nicklas |
@author nicklas |
2751 |
20 Oct 06 |
nicklas |
@version 2.0 |
2751 |
20 Oct 06 |
nicklas |
@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 |
Handle an error. If it is decided that the error is a final error |
2751 |
20 Oct 06 |
nicklas |
this method should rethrow the same or a different exception. If |
2751 |
20 Oct 06 |
nicklas |
if is decided that it is possible to continue with the current operation |
2751 |
20 Oct 06 |
nicklas |
<code>true</code> should be returned. If <code>false</code> is returned |
2751 |
20 Oct 06 |
nicklas |
it indicates that this error handled doesn't know how to handle the |
2751 |
20 Oct 06 |
nicklas |
error. The caller should try another error handler or throw an exception. |
2751 |
20 Oct 06 |
nicklas |
53 |
|
2751 |
20 Oct 06 |
nicklas |
@param t The error to handle |
2751 |
20 Oct 06 |
nicklas |
@return TRUE if the error was handled successfully and the execution should |
2751 |
20 Oct 06 |
nicklas |
continue with the next item |
2751 |
20 Oct 06 |
nicklas |
@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 |
} |