1 package org.jaxen; 2 3 import java.io.PrintStream ; 4 import java.io.PrintWriter ; 5 6 66 67 71 public class JaxenRuntimeException extends RuntimeException 72 { 73 private Throwable cause; 74 private boolean causeSet = false; 75 76 82 public JaxenRuntimeException(Throwable cause) 83 { 84 super(cause.getMessage()); 85 initCause(cause); 86 } 87 88 93 public JaxenRuntimeException(String message) { 94 super(message); 95 } 96 97 104 public Throwable getCause() { 105 return cause; 106 } 107 108 109 118 public Throwable initCause(Throwable cause) { 119 if (causeSet) throw new IllegalStateException ("Cause cannot be reset"); 120 if (cause == this) throw new IllegalArgumentException ("Exception cannot be its own cause"); 121 causeSet = true; 122 this.cause = cause; 123 return this; 124 } 125 126 131 public void printStackTrace ( PrintStream s ) 132 { 133 super.printStackTrace ( s ); 134 if (JaxenException.javaVersion < 1.4 && getCause() != null) { 135 s.print( "Caused by: " ); 136 getCause().printStackTrace( s ); 137 } 138 } 139 140 145 public void printStackTrace ( PrintWriter s ) 146 { 147 super.printStackTrace( s ); 148 if (JaxenException.javaVersion < 1.4 && getCause() != null) { 149 s.print( "Caused by: " ); 150 getCause().printStackTrace( s ); 151 } 152 } 153 154 } 155 | Popular Tags |