View Javadoc

1   /*
2    *  Copyright 2004 The Apache Software Foundation
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  package org.apache.commons.convert;
17  
18  /**
19   * ConversionException is used when a conversion has failed for some reason.
20   *
21   * @author Craig McClanahan
22   * @author Paulo Gaspar
23   * @author Stephen Colebourne
24   * @version $Id: ConversionException.java 155441 2005-02-26 13:19:22Z dirkv $
25   * @since 1.0
26   */
27  public class ConversionException extends IllegalArgumentException {
28  
29      /**
30       * The root cause of this <code>ConversionException</code>, compatible with
31       * JDK 1.4's extensions to <code>java.lang.Throwable</code>.
32       */
33      protected Throwable cause;
34      
35      /**
36       * Construct a new exception with the specified message.
37       *
38       * @param message  a message describing this exception
39       */
40      public ConversionException(String message) {
41          super(message);
42      }
43  
44      /**
45       * Construct a new exception with the specified root cause.
46       *
47       * @param cause  the root cause of this exception
48       */
49      public ConversionException(Throwable cause) {
50          super(cause.getMessage());
51          this.cause = cause;
52      }
53  
54      /**
55       * Construct a new exception with the specified message and root cause.
56       *
57       * @param message  a message describing this exception
58       * @param cause  the root cause of this exception
59       */
60      public ConversionException(String message, Throwable cause) {
61          super(message);
62          this.cause = cause;
63      }
64  
65      /**
66       * Gets the root cause of the exception.
67       * 
68       * @return the root cause
69       */
70      public Throwable getCause() {
71          return cause;
72      }
73  
74  }