001: /*
002: * Copyright (c) 1998-2008 Caucho Technology -- all rights reserved
003: *
004: * This file is part of Resin(R) Open Source
005: *
006: * Each copy or derived work must preserve the copyright notice and this
007: * notice unmodified.
008: *
009: * Resin Open Source is free software; you can redistribute it and/or modify
010: * it under the terms of the GNU General Public License as published by
011: * the Free Software Foundation; either version 2 of the License, or
012: * (at your option) any later version.
013: *
014: * Resin Open Source is distributed in the hope that it will be useful,
015: * but WITHOUT ANY WARRANTY; without even the implied warranty of
016: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
017: * of NON-INFRINGEMENT. See the GNU General Public License for more
018: * details.
019: *
020: * You should have received a copy of the GNU General Public License
021: * along with Resin Open Source; if not, write to the
022: * Free SoftwareFoundation, Inc.
023: * 59 Temple Place, Suite 330
024: * Boston, MA 02111-1307 USA
025: *
026: * @author Scott Ferguson
027: */
028:
029: package com.caucho.util;
030:
031: import java.io.PrintStream;
032: import java.io.PrintWriter;
033:
034: /**
035: * Base class for configuration exceptions. Thrown by RegistryNode
036: * classes.
037: */
038: public class RegistryException extends java.io.IOException implements
039: ExceptionWrapper {
040: private Throwable _rootCause;
041:
042: /**
043: * Create a null exception
044: */
045: public RegistryException() {
046: }
047:
048: /**
049: * Creates an exception with a message
050: */
051: public RegistryException(String msg) {
052: super (msg);
053: }
054:
055: /**
056: * Wraps an exception in the config exception
057: */
058: public RegistryException(String msg, Throwable e) {
059: super (msg);
060:
061: _rootCause = e;
062: }
063:
064: /**
065: * Wraps an exception in the config exception
066: */
067: public RegistryException(Throwable e) {
068: _rootCause = e;
069: }
070:
071: /**
072: * Returns the root cause, if any.
073: */
074: public Throwable getRootCause() {
075: return _rootCause;
076: }
077:
078: /**
079: * Prints the stack trace, preferring the root cause if it exists.
080: */
081: public void printStackTrace() {
082: if (_rootCause != null)
083: _rootCause.printStackTrace();
084: else
085: super .printStackTrace();
086: }
087:
088: /**
089: * Prints the stack trace, preferring the root cause if it exists.
090: */
091: public void printStackTrace(PrintStream os) {
092: if (_rootCause != null)
093: _rootCause.printStackTrace(os);
094: else
095: super .printStackTrace(os);
096: }
097:
098: /**
099: * Prints the stack trace, preferring the root cause if it exists.
100: */
101: public void printStackTrace(PrintWriter os) {
102: if (_rootCause != null)
103: _rootCause.printStackTrace(os);
104: else
105: super.printStackTrace(os);
106: }
107: }
|