001: /*
002: * $Id: DefinitionsFactoryException.java 471754 2006-11-06 14:55:09Z husted $
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: package org.apache.struts.tiles;
023:
024: /**
025: * Exception thrown when an error occurs while the factory tries to
026: * create a new instance mapper.
027: */
028: public class DefinitionsFactoryException extends TilesException {
029: /**
030: * Constructor.
031: */
032: public DefinitionsFactoryException() {
033: super ();
034: this .exception = null;
035: }
036:
037: /**
038: * Constructor.
039: * @param message The error or warning message.
040: */
041: public DefinitionsFactoryException(String message) {
042: super (message);
043: this .exception = null;
044: }
045:
046: /**
047: * Create a new <code>DefinitionsFactoryException</code> wrapping an existing exception.
048: *
049: * <p>The existing exception will be embedded in the new
050: * one and its message will become the default message for
051: * the DefinitionsFactoryException.</p>
052: *
053: * @param e The exception to be wrapped.
054: */
055: public DefinitionsFactoryException(Exception e) {
056: super ();
057: this .exception = e;
058: }
059:
060: /**
061: * Create a new <code>DefinitionsFactoryException</code> from an existing exception.
062: *
063: * <p>The existing exception will be embedded in the new
064: * one, but the new exception will have its own message.</p>
065: *
066: * @param message The detail message.
067: * @param e The exception to be wrapped.
068: */
069: public DefinitionsFactoryException(String message, Exception e) {
070: super (message);
071: this .exception = e;
072: }
073:
074: /**
075: * Return a detail message for this exception.
076: *
077: * <p>If there is a embedded exception, and if the DefinitionsFactoryException
078: * has no detail message of its own, this method will return
079: * the detail message from the embedded exception.</p>
080: *
081: * @return The error or warning message.
082: */
083: public String getMessage() {
084: String message = super .getMessage();
085:
086: if (message == null && exception != null) {
087: return exception.getMessage();
088: } else {
089: return message;
090: }
091: }
092:
093: /**
094: * Return the embedded exception, if any.
095: * @return The embedded exception, or <code>null</code> if there is none.
096: */
097: public Exception getException() {
098: return exception;
099: }
100:
101: //////////////////////////////////////////////////////////////////////
102: // Internal state.
103: //////////////////////////////////////////////////////////////////////
104:
105: /**
106: * Any "wrapped" exception will be exposed when this is serialized.
107: * @serial
108: */
109: private Exception exception;
110: }
|