KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * $Id: DefinitionsFactoryException.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    * Exception thrown when an error occurs while the factory tries to
24    * create a new instance mapper.
25    */

26 public class DefinitionsFactoryException extends TilesException
27 {
28   /**
29     * Constructor.
30     */

31   public DefinitionsFactoryException()
32     {
33     super();
34     this.exception = null;
35   }
36
37   /**
38     * Constructor.
39     * @param message The error or warning message.
40     */

41   public DefinitionsFactoryException(String JavaDoc message)
42     {
43     super(message);
44     this.exception = null;
45   }
46
47
48   /**
49     * Create a new <code>DefinitionsFactoryException</code> wrapping an existing exception.
50     *
51     * <p>The existing exception will be embedded in the new
52     * one and its message will become the default message for
53     * the DefinitionsFactoryException.</p>
54     *
55     * @param e The exception to be wrapped.
56     */

57   public DefinitionsFactoryException(Exception JavaDoc e)
58   {
59     super();
60     this.exception = e;
61   }
62
63
64   /**
65     * Create a new <code>DefinitionsFactoryException</code> from an existing exception.
66     *
67     * <p>The existing exception will be embedded in the new
68     * one, but the new exception will have its own message.</p>
69     *
70     * @param message The detail message.
71     * @param e The exception to be wrapped.
72     */

73   public DefinitionsFactoryException(String JavaDoc message, Exception JavaDoc e)
74   {
75     super(message);
76     this.exception = e;
77   }
78
79
80   /**
81     * Return a detail message for this exception.
82     *
83     * <p>If there is a embedded exception, and if the DefinitionsFactoryException
84     * has no detail message of its own, this method will return
85     * the detail message from the embedded exception.</p>
86     *
87     * @return The error or warning message.
88     */

89   public String JavaDoc getMessage ()
90   {
91     String JavaDoc message = super.getMessage ();
92
93     if (message == null && exception != null) {
94       return exception.getMessage();
95     } else {
96       return message;
97     }
98   }
99
100
101   /**
102     * Return the embedded exception, if any.
103     * @return The embedded exception, or <code>null</code> if there is none.
104     */

105   public Exception JavaDoc getException ()
106   {
107     return exception;
108   }
109
110   //////////////////////////////////////////////////////////////////////
111
// Internal state.
112
//////////////////////////////////////////////////////////////////////
113

114
115   /**
116    * Any "wrapped" exception will be exposed when this is serialized.
117    * @serial
118    */

119   private Exception JavaDoc exception;
120 }
121
Popular Tags