View Javadoc

1   /*
2    *  Copyright 2006-2007 the original author or authors.
3    *
4    *  Licensed under the Apache License, Version 2.0 (the "License");
5    *  you may not use this file except in compliance with the License.
6    *  You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   *  Unless required by applicable law or agreed to in writing, software
11   *  distributed under the License is distributed on an "AS IS" BASIS,
12   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   *  See the License for the specific language governing permissions and
14   *  limitations under the License.
15   */
16  
17  package net.sf.ezmorph;
18  
19  import org.apache.commons.lang.exception.NestableRuntimeException;
20  
21  /**
22   * A <strong>MorphException</strong> indicates that a call to
23   * <code>Morpher.morph()</code> has failed to complete successfully.<br>
24   * Based on common-beauntils ConversionException.<br>
25   *
26   * @author Andres Almiray <aalmiray@users.sourceforge.net>
27   */
28  public class MorphException extends NestableRuntimeException
29  {
30     private static final long serialVersionUID = -540093801787033824L;
31  
32     // ----------------------------------------------------------- Constructors
33  
34     /**
35      * The root cause of this <code>ConversionException</code>, compatible
36      * with JDK 1.4's extensions to <code>java.lang.Throwable</code>.
37      */
38     protected Throwable cause = null;
39  
40     /**
41      * Construct a new exception with the specified message.
42      *
43      * @param message The message describing this exception
44      */
45     public MorphException( String message )
46     {
47        super( message );
48     }
49  
50     /**
51      * Construct a new exception with the specified message and root cause.
52      *
53      * @param message The message describing this exception
54      * @param cause The root cause of this exception
55      */
56     public MorphException( String message, Throwable cause )
57     {
58        super( message );
59        this.cause = cause;
60     }
61  
62     // ------------------------------------------------------------- Properties
63  
64     /**
65      * Construct a new exception with the specified root cause.
66      *
67      * @param cause The root cause of this exception
68      */
69     public MorphException( Throwable cause )
70     {
71        super( cause.getMessage() );
72        this.cause = cause;
73     }
74  
75     /**
76      * Returns the cause of this exception.
77      *
78      * @return a Throwable that represents the cause of this exception
79      */
80     public Throwable getCause()
81     {
82        return this.cause;
83     }
84  }