1   /*
2    *  ResourceInstantiationException.java
3    *
4    *  Copyright (c) 1998-2001, 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.6 2001/11/16 10:35:59 valyt Exp $
14   */
15  
16  package gate.creole;
17  
18  import gate.util.*;
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      s.print("  Caused by:\n");
66      if(exception != null) exception.printStackTrace(s);
67    }
68  
69    /**
70     * Overriden so we can print the enclosed exception's stacktrace too.
71     */
72    public void printStackTrace(java.io.PrintWriter s) {
73      s.flush();
74      super.printStackTrace(s);
75      s.print("  Caused by:\n");
76      if(exception != null) exception.printStackTrace(s);
77    }
78  
79  } // ResourceInstantiationException
80