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