| ResourceInstantiationException.java |
1 /*
2 * ResourceInstantiationException.java
3 *
4 * Copyright (c) 1998-2004, 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, 23/Oct/2000
12 *
13 * $Id: ResourceInstantiationException.java,v 1.9 2004/07/21 17:10:03 akshay Exp $
14 */
15
16 package gate.creole;
17
18 import gate.util.GateException;
19
20 /** This exception indicates failure during instantiation of resources,
21 * which may be due to a number of causes:
22 * <UL>
23 * <LI>
24 * the resource metadata contains parameters that aren't available on
25 * the resource;
26 * <LI>
27 * the class for the resource cannot be found (e.g. because a Jar URL was
28 * incorrectly specified);
29 * <LI>
30 * because access to the resource class is denied by the class loader;
31 * <LI>
32 * because of insufficient or incorrect resource metadata.
33 * </UL>
34 */
35 public class ResourceInstantiationException extends GateException {
36 /** Debug flag */
37 private static final boolean DEBUG = false;
38 private Exception exception = null;
39
40 public ResourceInstantiationException() {
41 super();
42 }
43
44 public ResourceInstantiationException(String s) {
45 super(s);
46 }
47
48 public ResourceInstantiationException(Exception e) {
49 this.exception = e;
50 }
51
52 /**
53 * Overriden so we can print the enclosed exception's stacktrace too.
54 */
55 public void printStackTrace(){
56 printStackTrace(System.err);
57 }
58
59 /**
60 * Overriden so we can print the enclosed exception's stacktrace too.
61 */
62 public void printStackTrace(java.io.PrintStream s) {
63 s.flush();
64 super.printStackTrace(s);
65 if(exception != null){
66 s.print(" Caused by:\n");
67 exception.printStackTrace(s);
68 }
69 }
70
71 /**
72 * Overriden so we can print the enclosed exception's stacktrace too.
73 */
74 public void printStackTrace(java.io.PrintWriter s) {
75 s.flush();
76 super.printStackTrace(s);
77 if(exception != null){
78 s.print(" Caused by:\n");
79 exception.printStackTrace(s);
80 }
81 }
82
83 } // ResourceInstantiationException
84