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.transform;
  27 
  28 /**
  29  * Thrown when a problem with configuration with the Transformer Factories
  30  * exists. This error will typically be thrown when the class of a
  31  * transformation factory specified in the system properties cannot be found
  32  * or instantiated.
  33  */
  34 public class TransformerFactoryConfigurationError extends Error {
  35     private static final long serialVersionUID = -6527718720676281516L;
  36 
  37     /**
  38      * <code>Exception</code> for the
  39      *  <code>TransformerFactoryConfigurationError</code>.
  40      */
  41     private Exception exception;
  42 
  43     /**
  44      * Create a new <code>TransformerFactoryConfigurationError</code> with no
  45      * detail message.
  46      */
  47     public TransformerFactoryConfigurationError() {
  48 
  49         super();
  50 
  51         this.exception = null;
  52     }
  53 
  54     /**
  55      * Create a new <code>TransformerFactoryConfigurationError</code> with
  56      * the <code>String</code> specified as an error message.
  57      *
  58      * @param msg The error message for the exception.
  59      */
  60     public TransformerFactoryConfigurationError(String msg) {
  61 
  62         super(msg);
  63 
  64         this.exception = null;
  65     }
  66 
  67     /**
  68      * Create a new <code>TransformerFactoryConfigurationError</code> with a
  69      * given <code>Exception</code> base cause of the error.
  70      *
  71      * @param e The exception to be encapsulated in a
  72      * TransformerFactoryConfigurationError.
  73      */
  74     public TransformerFactoryConfigurationError(Exception e) {
  75 
  76         super(e.toString());
  77 
  78         this.exception = e;
  79     }
  80 
  81     /**
  82      * Create a new <code>TransformerFactoryConfigurationError</code> with the
  83      * given <code>Exception</code> base cause and detail message.
  84      *
  85      * @param e The exception to be encapsulated in a
  86      * TransformerFactoryConfigurationError
  87      * @param msg The detail message.
  88      */
  89     public TransformerFactoryConfigurationError(Exception e, String msg) {
  90 
  91         super(msg);
  92 
  93         this.exception = e;
  94     }
  95 
  96     /**
  97      * Return the message (if any) for this error . If there is no
  98      * message for the exception and there is an encapsulated
  99      * exception then the message of that exception will be returned.
 100      *
 101      * @return The error message.
 102      */
 103     public String getMessage() {
 104 
 105         String message = super.getMessage();
 106 
 107         if ((message == null) && (exception != null)) {
 108             return exception.getMessage();
 109         }
 110 
 111         return message;
 112     }
 113 
 114     /**
 115      * Return the actual exception (if any) that caused this exception to
 116      * be raised.
 117      *
 118      * @return The encapsulated exception, or null if there is none.
 119      */
 120     public Exception getException() {
 121         return exception;
 122     }
 123     /**
 124      * use the exception chaining mechanism of JDK1.4
 125     */
 126     @Override
 127     public Throwable getCause() {
 128         return exception;
 129     }
 130 }