1 /*
   2  * Copyright (c) 2000, 2005, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package javax.xml.parsers;
  27 
  28 /**
  29  * Thrown when a problem with configuration with the Parser Factories
  30  * exists. This error will typically be thrown when the class of a
  31  * parser factory specified in the system properties cannot be found
  32  * or instantiated.
  33  *
  34  * @author <a href="mailto:Jeff.Suttor@Sun.com">Jeff Suttor</a>
  35  * @since 1.4
  36  */
  37 
  38 public class FactoryConfigurationError extends Error {
  39     private static final long serialVersionUID = -827108682472263355L;
  40 
  41     /**
  42      *<code>Exception</code> that represents the error.
  43      */
  44     private Exception exception;
  45 
  46     /**
  47      * Create a new <code>FactoryConfigurationError</code> with no
  48      * detail mesage.
  49      */
  50 
  51     public FactoryConfigurationError() {
  52         super();
  53         this.exception = null;
  54     }
  55 
  56     /**
  57      * Create a new <code>FactoryConfigurationError</code> with
  58      * the <code>String </code> specified as an error message.
  59      *
  60      * @param msg The error message for the exception.
  61      */
  62 
  63     public FactoryConfigurationError(String msg) {
  64         super(msg);
  65         this.exception = null;
  66     }
  67 
  68 
  69     /**
  70      * Create a new <code>FactoryConfigurationError</code> with a
  71      * given <code>Exception</code> base cause of the error.
  72      *
  73      * @param e The exception to be encapsulated in a
  74      * FactoryConfigurationError.
  75      */
  76 
  77     public FactoryConfigurationError(Exception e) {
  78         super(e.toString());
  79         this.exception = e;
  80     }
  81 
  82     /**
  83      * Create a new <code>FactoryConfigurationError</code> with the
  84      * given <code>Exception</code> base cause and detail message.
  85      *
  86      * @param e The exception to be encapsulated in a
  87      * FactoryConfigurationError
  88      * @param msg The detail message.
  89      */
  90 
  91     public FactoryConfigurationError(Exception e, String msg) {
  92         super(msg);
  93         this.exception = e;
  94     }
  95 
  96 
  97     /**
  98      * Return the message (if any) for this error . If there is no
  99      * message for the exception and there is an encapsulated
 100      * exception then the message of that exception, if it exists will be
 101      * returned. Else the name of the encapsulated exception will be
 102      * returned.
 103      *
 104      * @return The error message.
 105      */
 106 
 107     public String getMessage () {
 108         String message = super.getMessage ();
 109 
 110         if (message == null && exception != null) {
 111             return exception.getMessage();
 112         }
 113 
 114         return message;
 115     }
 116 
 117     /**
 118      * Return the actual exception (if any) that caused this exception to
 119      * be raised.
 120      *
 121      * @return The encapsulated exception, or null if there is none.
 122      */
 123 
 124     public Exception getException () {
 125         return exception;
 126     }
 127 
 128     /**
 129      * use the exception chaining mechanism of JDK1.4
 130     */
 131     @Override
 132     public Throwable getCause() {
 133         return exception;
 134     }
 135 }