1 /* 2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * 4 * This code is free software; you can redistribute it and/or modify it 5 * under the terms of the GNU General Public License version 2 only, as 6 * published by the Free Software Foundation. Oracle designates this 7 * particular file as subject to the "Classpath" exception as provided 8 * by Oracle in the LICENSE file that accompanied this code. 9 * 10 * This code is distributed in the hope that it will be useful, but WITHOUT 11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 * version 2 for more details (a copy is included in the LICENSE file that 14 * accompanied this code). 15 * 16 * You should have received a copy of the GNU General Public License version 17 * 2 along with this work; if not, write to the Free Software Foundation, 18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 19 * 20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 21 * or visit www.oracle.com if you need additional information or have any 22 * questions. 23 */ 24 25 /* 26 * Copyright (c) 2009 by Oracle Corporation. All Rights Reserved. 27 */ 28 29 package javax.xml.stream; 30 31 /** 32 * An error class for reporting factory configuration errors. 33 * 34 * @version 1.0 35 * @author Copyright (c) 2009 by Oracle Corporation. All Rights Reserved. 36 * @since 1.6 37 */ 38 public class FactoryConfigurationError extends Error { 39 private static final long serialVersionUID = -2994412584589975744L; 40 41 Exception nested; 42 43 /** 44 * Default constructor 45 */ 46 public FactoryConfigurationError(){} 47 48 /** 49 * Construct an exception with a nested inner exception 50 * 51 * @param e the exception to nest 52 */ 53 public FactoryConfigurationError(java.lang.Exception e){ 54 nested = e; 55 } 56 57 /** 58 * Construct an exception with a nested inner exception 59 * and a message 60 * 61 * @param e the exception to nest 62 * @param msg the message to report 63 */ 64 public FactoryConfigurationError(java.lang.Exception e, java.lang.String msg){ 65 super(msg); 66 nested = e; 67 } 68 69 /** 70 * Construct an exception with a nested inner exception 71 * and a message 72 * 73 * @param msg the message to report 74 * @param e the exception to nest 75 */ 76 public FactoryConfigurationError(java.lang.String msg, java.lang.Exception e){ 77 super(msg); 78 nested = e; 79 } 80 81 /** 82 * Construct an exception with associated message 83 * 84 * @param msg the message to report 85 */ 86 public FactoryConfigurationError(java.lang.String msg) { 87 super(msg); 88 } 89 90 /** 91 * Return the nested exception (if any) 92 * 93 * @return the nested exception or null 94 */ 95 public Exception getException() { 96 return nested; 97 } 98 /** 99 * use the exception chaining mechanism of JDK1.4 100 */ 101 @Override 102 public Throwable getCause() { 103 return nested; 104 } 105 106 /** 107 * Report the message associated with this error 108 * 109 * @return the string value of the message 110 */ 111 public String getMessage() { 112 String msg = super.getMessage(); 113 if(msg != null) 114 return msg; 115 if(nested != null){ 116 msg = nested.getMessage(); 117 if(msg == null) 118 msg = nested.getClass().toString(); 119 } 120 return msg; 121 } 122 123 124 125 }