001: package org.apache.turbine.util;
002:
003: /*
004: * Licensed to the Apache Software Foundation (ASF) under one
005: * or more contributor license agreements. See the NOTICE file
006: * distributed with this work for additional information
007: * regarding copyright ownership. The ASF licenses this file
008: * to you under the Apache License, Version 2.0 (the
009: * "License"); you may not use this file except in compliance
010: * with the License. You may obtain a copy of the License at
011: *
012: * http://www.apache.org/licenses/LICENSE-2.0
013: *
014: * Unless required by applicable law or agreed to in writing,
015: * software distributed under the License is distributed on an
016: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017: * KIND, either express or implied. See the License for the
018: * specific language governing permissions and limitations
019: * under the License.
020: */
021:
022: import org.apache.commons.lang.exception.NestableException;
023:
024: /**
025: * The base class of all exceptions thrown by Turbine.
026: *
027: * It is intended to ease the debugging by carrying on the information
028: * about the exception which was caught and provoked throwing the
029: * current exception. Catching and rethrowing may occur multiple
030: * times, and provided that all exceptions except the first one
031: * are descendands of <code>TurbineException</code>, when the
032: * exception is finally printed out using any of the <code>
033: * printStackTrace()</code> methods, the stacktrace will contain
034: * the information about all exceptions thrown and caught on
035: * the way.
036: * <p> Running the following program
037: * <p><blockquote><pre>
038: * 1 import org.apache.turbine.util.TurbineException;
039: * 2
040: * 3 public class Test {
041: * 4 public static void main( String[] args ) {
042: * 5 try {
043: * 6 a();
044: * 7 } catch(Exception e) {
045: * 8 e.printStackTrace();
046: * 9 }
047: * 10 }
048: * 11
049: * 12 public static void a() throws TurbineException {
050: * 13 try {
051: * 14 b();
052: * 15 } catch(Exception e) {
053: * 16 throw new TurbineException("foo", e);
054: * 17 }
055: * 18 }
056: * 19
057: * 20 public static void b() throws TurbineException {
058: * 21 try {
059: * 22 c();
060: * 23 } catch(Exception e) {
061: * 24 throw new TurbineException("bar", e);
062: * 25 }
063: * 26 }
064: * 27
065: * 28 public static void c() throws TurbineException {
066: * 29 throw new Exception("baz");
067: * 30 }
068: * 31 }
069: * </pre></blockquote>
070: * <p>Yields the following stacktrace:
071: * <p><blockquote><pre>
072: * java.lang.Exception: baz: bar: foo
073: * at Test.c(Test.java:29)
074: * at Test.b(Test.java:22)
075: * rethrown as TurbineException: bar
076: * at Test.b(Test.java:24)
077: * at Test.a(Test.java:14)
078: * rethrown as TurbineException: foo
079: * at Test.a(Test.java:16)
080: * at Test.main(Test.java:6)
081: * </pre></blockquote><br>
082: *
083: * @author <a href="mailto:Rafal.Krzewski@e-point.pl">Rafal Krzewski</a>
084: * @author <a href="mailto:dlr@finemaltcoding.com">Daniel Rall</a>
085: * @author <a href="mailto:quintonm@bellsouth.net">Quinton McCombs</a>
086: * @version $Id: TurbineException.java 534527 2007-05-02 16:10:59Z tv $
087: */
088: public class TurbineException extends NestableException {
089: /** Serial Version UID */
090: private static final long serialVersionUID = -2978139489274739700L;
091:
092: /**
093: * Constructs a new <code>TurbineException</code> without specified
094: * detail message.
095: */
096: public TurbineException() {
097: }
098:
099: /**
100: * Constructs a new <code>TurbineException</code> with specified
101: * detail message.
102: *
103: * @param msg The error message.
104: */
105: public TurbineException(String msg) {
106: super (msg);
107: }
108:
109: /**
110: * Constructs a new <code>TurbineException</code> with specified
111: * nested <code>Throwable</code>.
112: *
113: * @param nested The exception or error that caused this exception
114: * to be thrown.
115: */
116: public TurbineException(Throwable nested) {
117: super (nested);
118: }
119:
120: /**
121: * Constructs a new <code>TurbineException</code> with specified
122: * detail message and nested <code>Throwable</code>.
123: *
124: * @param msg The error message.
125: * @param nested The exception or error that caused this exception
126: * to be thrown.
127: */
128: public TurbineException(String msg, Throwable nested) {
129: super(msg, nested);
130: }
131: }
|