1 21 22 23 package nu.xom; 24 25 41 public class XMLException extends RuntimeException { 42 43 private Throwable cause; 44 45 46 56 public XMLException(String message, Throwable cause) { 57 super(message); 58 this.initCause(cause); 59 } 60 61 62 70 public XMLException(String message) { 71 super(message); 72 } 73 74 75 83 public Throwable getCause() { 84 return this.cause; 85 } 86 87 88 private boolean causeSet = false; 91 92 93 114 public Throwable initCause(Throwable cause) { 115 116 if (causeSet) { 117 throw new IllegalStateException ("Can't overwrite cause"); 118 } 119 else if (cause == this) { 120 throw new IllegalArgumentException ("Self-causation not permitted"); 121 } 122 else this.cause = cause; 123 causeSet = true; 124 return this; 125 126 } 127 128 129 } 130 | Popular Tags |