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