KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > caucho > util > RegistryException


1 /*
2  * Copyright (c) 1998-2006 Caucho Technology -- all rights reserved
3  *
4  * This file is part of Resin(R) Open Source
5  *
6  * Each copy or derived work must preserve the copyright notice and this
7  * notice unmodified.
8  *
9  * Resin Open Source is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * Resin Open Source is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
17  * of NON-INFRINGEMENT. See the GNU General Public License for more
18  * details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with Resin Open Source; if not, write to the
22  * Free SoftwareFoundation, Inc.
23  * 59 Temple Place, Suite 330
24  * Boston, MA 02111-1307 USA
25  *
26  * @author Scott Ferguson
27  */

28
29 package com.caucho.util;
30
31 import java.io.PrintStream JavaDoc;
32 import java.io.PrintWriter JavaDoc;
33
34 /**
35  * Base class for configuration exceptions. Thrown by RegistryNode
36  * classes.
37  */

38 public class RegistryException extends java.io.IOException JavaDoc
39   implements ExceptionWrapper {
40   private Throwable JavaDoc _rootCause;
41
42   /**
43    * Create a null exception
44    */

45   public RegistryException()
46   {
47   }
48
49   /**
50    * Creates an exception with a message
51    */

52   public RegistryException(String JavaDoc msg)
53   {
54     super(msg);
55   }
56
57   /**
58    * Wraps an exception in the config exception
59    */

60   public RegistryException(String JavaDoc msg, Throwable JavaDoc e)
61   {
62     super(msg);
63
64     _rootCause = e;
65   }
66
67   /**
68    * Wraps an exception in the config exception
69    */

70   public RegistryException(Throwable JavaDoc e)
71   {
72     _rootCause = e;
73   }
74
75   /**
76    * Returns the root cause, if any.
77    */

78   public Throwable JavaDoc getRootCause()
79   {
80     return _rootCause;
81   }
82
83   /**
84    * Prints the stack trace, preferring the root cause if it exists.
85    */

86   public void printStackTrace()
87   {
88     if (_rootCause != null)
89       _rootCause.printStackTrace();
90     else
91       super.printStackTrace();
92   }
93
94   /**
95    * Prints the stack trace, preferring the root cause if it exists.
96    */

97   public void printStackTrace(PrintStream JavaDoc os)
98   {
99     if (_rootCause != null)
100       _rootCause.printStackTrace(os);
101     else
102       super.printStackTrace(os);
103   }
104
105   /**
106    * Prints the stack trace, preferring the root cause if it exists.
107    */

108   public void printStackTrace(PrintWriter JavaDoc os)
109   {
110     if (_rootCause != null)
111       _rootCause.printStackTrace(os);
112     else
113       super.printStackTrace(os);
114   }
115 }
116
117
118
Popular Tags