1 package com.sun.org.apache.xml.internal.security.exceptions; 2 3 import java.io.PrintStream ; 4 import java.io.PrintWriter ; 5 import java.text.MessageFormat ; 6 7 import com.sun.org.apache.xml.internal.security.utils.Constants; 8 import com.sun.org.apache.xml.internal.security.utils.I18n; 9 10 42 public class XMLSecurityRuntimeException 43 extends RuntimeException { 44 47 private static final long serialVersionUID = 1L; 48 49 50 protected Exception originalException = null; 51 52 53 protected String msgID; 54 55 59 public XMLSecurityRuntimeException() { 60 61 super("Missing message string"); 62 63 this.msgID = null; 64 this.originalException = null; 65 } 66 67 72 public XMLSecurityRuntimeException(String _msgID) { 73 74 super(I18n.getExceptionMessage(_msgID)); 75 76 this.msgID = _msgID; 77 this.originalException = null; 78 } 79 80 86 public XMLSecurityRuntimeException(String _msgID, Object exArgs[]) { 87 88 super(MessageFormat.format(I18n.getExceptionMessage(_msgID), exArgs)); 89 90 this.msgID = _msgID; 91 this.originalException = null; 92 } 93 94 99 public XMLSecurityRuntimeException(Exception _originalException) { 100 101 super("Missing message ID to locate message string in resource bundle \"" 102 + Constants.exceptionMessagesResourceBundleBase 103 + "\". Original Exception was a " 104 + _originalException.getClass().getName() + " and message " 105 + _originalException.getMessage()); 106 107 this.originalException = _originalException; 108 } 109 110 116 public XMLSecurityRuntimeException(String _msgID, Exception _originalException) { 117 118 super(I18n.getExceptionMessage(_msgID, _originalException)); 119 120 this.msgID = _msgID; 121 this.originalException = _originalException; 122 } 123 124 131 public XMLSecurityRuntimeException(String _msgID, Object exArgs[], 132 Exception _originalException) { 133 134 super(MessageFormat.format(I18n.getExceptionMessage(_msgID), exArgs)); 135 136 this.msgID = _msgID; 137 this.originalException = _originalException; 138 } 139 140 145 public String getMsgID() { 146 147 if (msgID == null) { 148 return "Missing message ID"; 149 } 150 return msgID; 151 } 152 153 154 public String toString() { 155 156 String s = this.getClass().getName(); 157 String message = super.getLocalizedMessage(); 158 159 if (message != null) { 160 message = s + ": " + message; 161 } else { 162 message = s; 163 } 164 165 if (originalException != null) { 166 message = message + "\nOriginal Exception was " 167 + originalException.toString(); 168 } 169 170 return message; 171 } 172 173 177 public void printStackTrace() { 178 179 synchronized (System.err) { 180 super.printStackTrace(System.err); 181 182 if (this.originalException != null) { 183 this.originalException.printStackTrace(System.err); 184 } 185 } 186 } 187 188 193 public void printStackTrace(PrintWriter printwriter) { 194 195 super.printStackTrace(printwriter); 196 197 if (this.originalException != null) { 198 this.originalException.printStackTrace(printwriter); 199 } 200 } 201 202 207 public void printStackTrace(PrintStream printstream) { 208 209 super.printStackTrace(printstream); 210 211 if (this.originalException != null) { 212 this.originalException.printStackTrace(printstream); 213 } 214 } 215 216 221 public Exception getOriginalException() { 222 return originalException; 223 } 224 } | Popular Tags |