GateException.java |
1 /* 2 * GateException.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/01/2000 12 * 13 * $Id: GateException.java,v 1.12 2005/02/14 14:50:16 valyt Exp $ 14 */ 15 16 package gate.util; 17 18 import java.io.PrintStream; 19 import java.io.PrintWriter; 20 21 /** A superclass for exceptions in the GATE packages. Can be used 22 * to catch any internal exception thrown by the GATE libraries. 23 * (Of course 24 * other types of exception may be thrown, but these will be from other 25 * sources such as the Java core API.) 26 */ 27 public class GateException extends Exception { 28 29 /** Debug flag */ 30 private static final boolean DEBUG = false; 31 32 protected Throwable e; 33 34 public GateException() { 35 super(); 36 } 37 38 public GateException(String s) { 39 super(s); 40 } 41 42 public GateException(Throwable e) { 43 super(e.toString()); 44 this.e = e; 45 } 46 47 public GateException(String message, Throwable e) { 48 super(message); 49 this.e = e; 50 } 51 52 53 /** 54 * Overridden so we can print the enclosed exception's stack trace too. 55 */ 56 public void printStackTrace(){ 57 printStackTrace(System.err); 58 } 59 60 /** 61 * Overridden so we can print the enclosed exception's stack trace too. 62 */ 63 public void printStackTrace(PrintStream s) { 64 s.flush(); 65 super.printStackTrace(s); 66 if(e != null){ 67 s.print(" Caused by:\n"); 68 e.printStackTrace(s); 69 } 70 } 71 72 /** 73 * Overridden so we can print the enclosed exception's stack trace too. 74 */ 75 public void printStackTrace(PrintWriter s) { 76 s.flush(); 77 super.printStackTrace(s); 78 if(e != null){ 79 s.print(" Caused by:\n"); 80 e.printStackTrace(s); 81 } 82 } 83 84 } // GateException 85