KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > struts > tiles > TilesException


1 /*
2  * $Id: TilesException.java 54929 2004-10-16 16:38:42Z germuska $
3  *
4  * Copyright 1999-2004 The Apache Software Foundation.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */

18
19
20 package org.apache.struts.tiles;
21
22
23 /**
24  * Root class for all Tiles-exceptions.
25  */

26 public class TilesException extends Exception JavaDoc
27 {
28
29
30   /**
31    * Any "wrapped" exception will be exposed when this is serialized.
32    * @serial
33    */

34   private Exception JavaDoc exception;
35   /**
36     * Constructor.
37     */

38   public TilesException()
39     {
40     super();
41     this.exception = null;
42   }
43
44   /**
45     * Constructor.
46     * @param message The error or warning message.
47     */

48   public TilesException(String JavaDoc message)
49     {
50     super(message);
51     this.exception = null;
52   }
53
54
55   /**
56     * Create a new <code>TilesException</code> wrapping an existing exception.
57     *
58     * <p>The existing exception will be embedded in the new
59     * one, and its message will become the default message for
60     * the TilesException.</p>
61     *
62     * @param e The exception to be wrapped.
63     */

64   public TilesException(Exception JavaDoc e)
65   {
66     super();
67     this.exception = e;
68   }
69
70
71   /**
72     * Create a new <code>TilesException</code> from an existing exception.
73     *
74     * <p>The existing exception will be embedded in the new
75     * one, but the new exception will have its own message.</p>
76     *
77     * @param message The detail message.
78     * @param e The exception to be wrapped.
79     */

80   public TilesException(String JavaDoc message, Exception JavaDoc e)
81   {
82     super(message);
83     this.exception = e;
84   }
85
86
87   /**
88     * Return a detail message for this exception.
89     *
90     * <p>If there is a embedded exception, and if the TilesException
91     * has no detail message of its own, this method will return
92     * the detail message from the embedded exception.</p>
93     *
94     * @return The error or warning message.
95     */

96   public String JavaDoc getMessage ()
97   {
98     String JavaDoc message = super.getMessage ();
99
100     if (message == null && exception != null) {
101       return exception.getMessage();
102     } else {
103       return message;
104     }
105   }
106
107
108   /**
109     * Return the embedded exception, if any.
110     *
111     * @return The embedded exception, or <code>null</code> if there is none.
112     */

113   public Exception JavaDoc getException ()
114   {
115     return exception;
116   }
117
118 }
119
Popular Tags