View Javadoc
1   /*
2    * reserved comment block
3    * DO NOT REMOVE OR ALTER!
4    */
5   /*
6    * Copyright 1999-2004 The Apache Software Foundation.
7    *
8    * Licensed under the Apache License, Version 2.0 (the "License");
9    * you may not use this file except in compliance with the License.
10   * You may obtain a copy of the License at
11   *
12   *     http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing, software
15   * distributed under the License is distributed on an "AS IS" BASIS,
16   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17   * See the License for the specific language governing permissions and
18   * limitations under the License.
19   */
20  /*
21   * $Id: WrappedRuntimeException.java,v 1.2.4.1 2005/09/15 08:16:00 suresh_emailid Exp $
22   */
23  package com.sun.org.apache.xml.internal.utils;
24  
25  /**
26   * This class is for throwing important checked exceptions
27   * over non-checked methods.  It should be used with care,
28   * and in limited circumstances.
29   */
30  public class WrappedRuntimeException extends RuntimeException
31  {
32      static final long serialVersionUID = 7140414456714658073L;
33  
34    /** Primary checked exception.
35     *  @serial          */
36    private Exception m_exception;
37  
38    /**
39     * Construct a WrappedRuntimeException from a
40     * checked exception.
41     *
42     * @param e Primary checked exception
43     */
44    public WrappedRuntimeException(Exception e)
45    {
46  
47      super(e.getMessage());
48  
49      m_exception = e;
50    }
51  
52    /**
53     * Constructor WrappedRuntimeException
54     *
55     *
56     * @param msg Exception information.
57     * @param e Primary checked exception
58     */
59    public WrappedRuntimeException(String msg, Exception e)
60    {
61  
62      super(msg);
63  
64      m_exception = e;
65    }
66  
67    /**
68     * Get the checked exception that this runtime exception wraps.
69     *
70     * @return The primary checked exception
71     */
72    public Exception getException()
73    {
74      return m_exception;
75    }
76  }