1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one or more 3 * contributor license agreements. See the NOTICE file distributed with 4 * this work for additional information regarding copyright ownership. 5 * The ASF licenses this file to You under the Apache License, Version 2.0 6 * (the "License"); you may not use this file except in compliance with 7 * the License. You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 18 // $Id: FactoryConfigurationError.java 569980 2007-08-27 03:58:15Z mrglavas $ 19 20 package javax.xml.parsers; 21 22 /** 23 * Thrown when a problem with configuration with the Parser Factories 24 * exists. This error will typically be thrown when the class of a 25 * parser factory specified in the system properties cannot be found 26 * or instantiated. 27 * 28 * @author <a href="mailto:Jeff.Suttor@Sun.com">Jeff Suttor</a> 29 * @version $Revision: 569980 $, $Date: 2007-08-26 20:58:15 -0700 (Sun, 26 Aug 2007) $ 30 */ 31 32 public class FactoryConfigurationError extends Error { 33 34 /** 35 *<code>Exception</code> that represents the error. 36 */ 37 private Exception exception; 38 39 /** 40 * Create a new <code>FactoryConfigurationError</code> with no 41 * detail message. 42 */ 43 FactoryConfigurationError()44 public FactoryConfigurationError() { 45 this.exception = null; 46 } 47 48 /** 49 * Create a new <code>FactoryConfigurationError</code> with 50 * the <code>String </code> specified as an error message. 51 * 52 * @param msg The error message for the exception. 53 */ 54 FactoryConfigurationError(String msg)55 public FactoryConfigurationError(String msg) { 56 super(msg); 57 this.exception = null; 58 } 59 60 61 /** 62 * Create a new <code>FactoryConfigurationError</code> with a 63 * given <code>Exception</code> base cause of the error. 64 * 65 * @param e The exception to be encapsulated in a 66 * FactoryConfigurationError. 67 */ 68 FactoryConfigurationError(Exception e)69 public FactoryConfigurationError(Exception e) { 70 super(e.toString()); 71 this.exception = e; 72 } 73 74 /** 75 * Create a new <code>FactoryConfigurationError</code> with the 76 * given <code>Exception</code> base cause and detail message. 77 * 78 * @param e The exception to be encapsulated in a 79 * FactoryConfigurationError 80 * @param msg The detail message. 81 */ 82 FactoryConfigurationError(Exception e, String msg)83 public FactoryConfigurationError(Exception e, String msg) { 84 super(msg); 85 this.exception = e; 86 } 87 88 89 /** 90 * Return the message (if any) for this error . If there is no 91 * message for the exception and there is an encapsulated 92 * exception then the message of that exception, if it exists will be 93 * returned. Else the name of the encapsulated exception will be 94 * returned. 95 * 96 * @return The error message. 97 */ 98 getMessage()99 public String getMessage () { 100 String message = super.getMessage (); 101 102 if (message == null && exception != null) { 103 return exception.getMessage(); 104 } 105 106 return message; 107 } 108 109 /** 110 * Return the actual exception (if any) that caused this exception to 111 * be raised. 112 * 113 * @return The encapsulated exception, or null if there is none. 114 */ 115 getException()116 public Exception getException () { 117 return exception; 118 } 119 } 120