01 /*
02 * PersistenceException.java
03 *
04 * Copyright (c) 1995-2010, The University of Sheffield. See the file
05 * COPYRIGHT.txt in the software or at http://gate.ac.uk/gate/COPYRIGHT.txt
06 *
07 * This file is part of GATE (see http://gate.ac.uk/), and is free
08 * software, licenced under the GNU Library General Public License,
09 * Version 2, June 1991 (in the distribution as file licence.html,
10 * and also available at http://gate.ac.uk/gate/licence.html).
11 *
12 * Hamish Cunningham, 19/Jan/2001
13 *
14 * $Id: PersistenceException.java 12006 2009-12-01 17:24:28Z thomas_heitz $
15 */
16
17 package gate.persist;
18
19 import gate.util.GateException;
20
21 /** This exception indicates failure during persistence operations.
22 */
23 public class PersistenceException extends GateException {
24 /** Debug flag */
25 private static final boolean DEBUG = false;
26
27 /** Default construction */
28 public PersistenceException() { super(); }
29
30 /** Construction from string */
31 public PersistenceException(String s) { super(s); }
32
33 /** Construction from exception */
34 public PersistenceException(Exception e) {
35 super(e.toString());
36 this.exception = e;
37 }
38
39 /** Construction from both string and exception */
40 public PersistenceException(String s, Exception e) {
41 super(s);
42 this.exception = e;
43 }
44
45 /**
46 * Overridden so we can print the enclosed exception's stacktrace too.
47 */
48 public void printStackTrace(){
49 printStackTrace(System.err);
50 }
51
52 /**
53 * Overridden so we can print the enclosed exception's stacktrace too.
54 */
55 public void printStackTrace(java.io.PrintStream s) {
56 s.flush();
57 super.printStackTrace(s);
58 s.print(" Caused by:\n");
59 if(exception != null) exception.printStackTrace(s);
60 }
61
62 /**
63 * Overridden so we can print the enclosed exception's stacktrace too.
64 */
65 public void printStackTrace(java.io.PrintWriter s) {
66 s.flush();
67 super.printStackTrace(s);
68 s.print(" Caused by:\n");
69 if(exception != null) exception.printStackTrace(s);
70 }
71
72 Exception exception = null;
73 } // PersistenceException
|