KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > sapia > util > ApplicationStarterException


1 package org.sapia.util;
2
3
4 // Import of Sun's JDK classes
5
// ---------------------------
6
import java.io.PrintStream JavaDoc;
7 import java.io.PrintWriter JavaDoc;
8
9
10 /**
11  * This exception is thrown by the <CODE>ApplicationStarter</CODE> when an
12  * error prevent it from starting an application.
13  *
14  * @author Jean-Cedric Desrochers
15  * <dl>
16  * <dt><b>Copyright:</b><dd>Copyright &#169; 2002-2003 <a HREF="http://www.sapia-oss.org">Sapia Open Source Software</a>. All Rights Reserved.</dd></dt>
17  * <dt><b>License:</b><dd>Read the license.txt file of the jar or visit the
18  * <a HREF="http://www.sapia-oss.org/license.html">license page</a> at the Sapia OSS web site</dd></dt>
19  * </dl>
20  */

21 public class ApplicationStarterException extends Exception JavaDoc {
22   /////////////////////////////////////////////////////////////////////////////////////////
23
///////////////////////////////// INSTANCE ATTRIBUTES /////////////////////////////////
24
/////////////////////////////////////////////////////////////////////////////////////////
25

26   /** The source error that is encapsulated in this exception. */
27   private Throwable JavaDoc _theSourceError;
28
29   /////////////////////////////////////////////////////////////////////////////////////////
30
//////////////////////////////////// CONSTRUCTORS /////////////////////////////////////
31
/////////////////////////////////////////////////////////////////////////////////////////
32

33   /**
34    * Creates a new ApplicationStarterException instance with the arguments passed in.
35    *
36    * @param aMessage The message describing the error.
37    * @param aSourceError The source error to encapsulate.
38    */

39   public ApplicationStarterException(String JavaDoc aMessage, Throwable JavaDoc aSourceError) {
40     super(aMessage);
41     _theSourceError = aSourceError;
42   }
43
44   /////////////////////////////////////////////////////////////////////////////////////////
45
////////////////////////////////// ACCESSOR METHODS ///////////////////////////////////
46
/////////////////////////////////////////////////////////////////////////////////////////
47

48   /**
49    * Returns the source error encapsulated in this exception.
50    *
51    * @return The source error encapsulated in this exception.
52    */

53   public Throwable JavaDoc getSourceError() {
54     return _theSourceError;
55   }
56
57   /////////////////////////////////////////////////////////////////////////////////////////
58
////////////////////////////////// OVERRIDEN METHODS //////////////////////////////////
59
/////////////////////////////////////////////////////////////////////////////////////////
60

61   /**
62    * Prints the stack trace of this exception to the standard error stream.
63    */

64   public void printStackTrace() {
65     printStackTrace(System.err);
66   }
67
68   /**
69    * Prints the stack trace of this exception to the print writer passed in.
70    */

71   public void printStackTrace(PrintWriter JavaDoc anOutput) {
72     super.printStackTrace(anOutput);
73
74     if (_theSourceError != null) {
75       anOutput.print("\n---> NESTED EXCEPTION IS: ");
76       _theSourceError.printStackTrace(anOutput);
77     }
78   }
79
80   /**
81    * Prints the stack trace of this exception to the print stream passed in.
82    */

83   public void printStackTrace(PrintStream JavaDoc anOutput) {
84     super.printStackTrace(anOutput);
85
86     if (_theSourceError != null) {
87       anOutput.print("\n---> NESTED EXCEPTION IS: ");
88       _theSourceError.printStackTrace(anOutput);
89     }
90   }
91 }
92
Popular Tags