1
2
3
4
5
6 package org.astrogrid.dataservice.queriers;
7
8 import java.io.IOException;
9
10
11 /***
12 * A generalised Exception for wrapping whatever specific exception is thrown
13 * in the database access (the querier) layer. This is because some queriers
14 * will return SQL exceptions, some will have nothing to do with SQL and return
15 * other wierd specific exceptions, but the interface above that should be clean
16 * <p>
17 * The original exception should wherever possible be preserved as the cause
18 * <p>
19 * I would have much rather used IOException directly instead of making a new one,
20 * but for some reason IOException has no easy constructor that takes a cause.
21 *
22 * @author M Hill
23 */
24
25 public class DatabaseAccessException extends QuerierPluginException
26 {
27 /***
28 * Constructor taking the cause of the error (an exception/error) and
29 * a message describing the context
30 */
31 public DatabaseAccessException(String message, Throwable cause)
32 {
33 super(message, cause);
34 }
35
36 /***
37 * Convenience constructor that just takes the cause of the error
38 */
39 public DatabaseAccessException(Throwable cause)
40 {
41 super(cause);
42 }
43
44 /***
45 * THis constructor should NOT be used when catching & rethrowing
46 * exceptions - in such cases use a constructor which takes a throwable, to
47 * preserve the original information
48 */
49 public DatabaseAccessException(String message)
50 {
51 super(message);
52 }
53
54 public static void main(String args[]) throws DatabaseAccessException
55 {
56 throw new DatabaseAccessException("DAE Message", new IOException("IOE"));
57 }
58
59 }
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93