1 /*
   2  * reserved comment block
   3  * DO NOT REMOVE OR ALTER!
   4  */
   5 /*
   6  * Licensed to the Apache Software Foundation (ASF) under one or more
   7  * contributor license agreements.  See the NOTICE file distributed with
   8  * this work for additional information regarding copyright ownership.
   9  * The ASF licenses this file to You under the Apache License, Version 2.0
  10  * (the "License"); you may not use this file except in compliance with
  11  * the License.  You may obtain a copy of the License at
  12  *
  13  *      http://www.apache.org/licenses/LICENSE-2.0
  14  *
  15  * Unless required by applicable law or agreed to in writing, software
  16  * distributed under the License is distributed on an "AS IS" BASIS,
  17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  18  * See the License for the specific language governing permissions and
  19  * limitations under the License.
  20  */
  21 
  22 package com.sun.org.apache.xerces.internal.xni;
  23 
  24 /**
  25  * This exception is the base exception of all XNI exceptions. It
  26  * can be constructed with an error message or used to wrap another
  27  * exception object.
  28  * <p>
  29  * <strong>Note:</strong> By extending the Java
  30  * <code>RuntimeException</code>, XNI handlers and components are
  31  * not required to catch XNI exceptions but may explicitly catch
  32  * them, if so desired.
  33  *
  34  * @author Andy Clark, IBM
  35  *
  36  * @version $Id: XNIException.java,v 1.6 2010-11-01 04:40:19 joehw Exp $
  37  */
  38 public class XNIException
  39     extends RuntimeException {
  40 
  41     /** Serialization version. */
  42     static final long serialVersionUID = 9019819772686063775L;
  43 
  44     //
  45     // Data
  46     //
  47 
  48     /** The wrapped exception. */
  49     private Exception fException;
  50 
  51     //
  52     // Constructors
  53     //
  54 
  55     /**
  56      * Constructs an XNI exception with a message.
  57      *
  58      * @param message The exception message.
  59      */
  60     public XNIException(String message) {
  61         super(message);
  62     } // <init>(String)
  63 
  64     /**
  65      * Constructs an XNI exception with a wrapped exception.
  66      *
  67      * @param exception The wrapped exception.
  68      */
  69     public XNIException(Exception exception) {
  70         super(exception.getMessage());
  71         fException = exception;
  72     } // <init>(Exception)
  73 
  74     /**
  75      * Constructs an XNI exception with a message and wrapped exception.
  76      *
  77      * @param message The exception message.
  78      * @param exception The wrapped exception.
  79      */
  80     public XNIException(String message, Exception exception) {
  81         super(message);
  82         fException = exception;
  83     } // <init>(Exception,String)
  84 
  85     //
  86     // Public methods
  87     //
  88 
  89     /** Returns the wrapped exception. */
  90     public Exception getException() {
  91         return fException;
  92     } // getException():Exception
  93 
  94     public Throwable getCause() {
  95        return fException;
  96     }
  97 } // class QName