01: /*
02: * Copyright (C) 2007 Rob Manning
03: * manningr@users.sourceforge.net
04: *
05: * This library is free software; you can redistribute it and/or
06: * modify it under the terms of the GNU Lesser General Public
07: * License as published by the Free Software Foundation; either
08: * version 2.1 of the License, or (at your option) any later version.
09: *
10: * This library is distributed in the hope that it will be useful,
11: * but WITHOUT ANY WARRANTY; without even the implied warranty of
12: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13: * Lesser General Public License for more details.
14: *
15: * You should have received a copy of the GNU Lesser General Public
16: * License along with this library; if not, write to the Free Software
17: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18: */
19: package net.sourceforge.squirrel_sql.fw.util;
20:
21: /**
22: * An interface that will allow plugin writers to customize the MessageHandler
23: * in SQuirreL to handle sometimes cryptic messages embedded in SQLExceptions
24: * from JDBC drivers.(FR#1731251)
25: *
26: * @author manningr
27: */
28: public interface ExceptionFormatter {
29:
30: /**
31: * Returns a boolean indicating whether or not this formatter can format the
32: * specified exception.
33: *
34: * @param t the exception to determine formatting compatibility
35: *
36: * @return a boolean value to indicate whether format should be called on the
37: * given throwable
38: */
39: boolean formatsException(Throwable t);
40:
41: /**
42: * Returns a custom-formatted message based on the contents of the specified
43: * Throwable. An exception can be thrown to indicate that custom formatting
44: * couldn't be done and that the default formatting should be applied.
45: *
46: *
47: * @param t the Throwable to be formatted
48: *
49: * @return A formatted version of the message encapsulated by the specified
50: * throwable.
51: *
52: * @throws Exception in the event that the specified Throwable for whatever
53: * reason could not be formatted, an exception can be thrown to
54: * indicate that custom formatting wasn't done and that the
55: * default formatting should be applied.
56: */
57: String format(Throwable t) throws Exception;
58:
59: }
|