]> review.fuel-infra Code Review - packages/trusty/mysql-wsrep-5.6.git/blob
9afd8e63099950de200239e803066540fa8437c6
[packages/trusty/mysql-wsrep-5.6.git] /
1 /*
2    Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
3
4    This program is free software; you can redistribute it and/or modify
5    it under the terms of the GNU General Public License as published by
6    the Free Software Foundation; version 2 of the License.
7
8    This program is distributed in the hope that it will be useful,
9    but WITHOUT ANY WARRANTY; without even the implied warranty of
10    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11    GNU General Public License for more details.
12
13    You should have received a copy of the GNU General Public License
14    along with this program; if not, write to the Free Software
15    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
16 */
17
18 package com.mysql.clusterj;
19
20 /**
21  * ClusterJException is the base for all ClusterJ exceptions.
22  * Applications can catch ClusterJException to be notified of
23  * all ClusterJ reported issues.
24  * <p>
25  * Exceptions are in three general categories: User exceptions,
26  * Datastore exceptions, and Internal exceptions.
27  * <ul><li>User exceptions are caused by user error, for example
28  * providing a connect string that refers to an unavailable
29  * host or port.
30  * <ul><li>If a user exception is detected during bootstrapping
31  * (acquiring a SessionFactory), it is thrown as a fatal exception.
32  * {@link ClusterJFatalUserException}
33  * </li><li>If an exception is detected during initialization of a
34  * persistent interface, for example annotating a column that
35  * doesn't exist in the mapped table, it is reported as a user
36  * exception. {@link ClusterJUserException}
37  * </li></ul>
38  * </li><li>Datastore exceptions report conditions that result
39  * from datastore operations after bootstrapping. For example,
40  * duplicate keys on insert, or record does not exist on delete.
41  * {@link ClusterJDatastoreException}
42  * </li><li>Internal exceptions report conditions that are caused
43  * by errors in implementation. These exceptions should be reported
44  * as bugs. {@link ClusterJFatalInternalException}
45  * </li></ul>
46  */
47 public class ClusterJException extends RuntimeException {
48
49     private static final long serialVersionUID = 3803389948396170712L;
50
51     public ClusterJException(String message) {
52         super(message);
53     }
54
55     public ClusterJException(String message, Throwable t) {
56         super(message + " Caused by " + t.getClass().getName() + ":" + t.getMessage(), t);
57     }
58
59     public ClusterJException(Throwable t) {
60         super(t);
61     }
62
63     @Override
64     public synchronized void printStackTrace(java.io.PrintStream s) {
65         synchronized (s) {
66             super.printStackTrace(s);
67             Throwable cause = getCause();
68             if (cause != null) {
69                 getCause().printStackTrace(s);
70             }
71         }
72     }
73 }