1 45 package org.openejb; 46 47 import java.io.PrintStream ; 48 import java.io.PrintWriter ; 49 50 86 public class OpenEJBException extends Exception { 87 88 89 private String message = "error.unknown"; 90 91 92 private Throwable rootCause; 93 94 100 public OpenEJBException() { 101 super(); 102 } 103 104 112 public OpenEJBException(String message) { 113 super( message ); 114 this.message = message; 115 } 116 117 125 public OpenEJBException(Throwable rootCause) { 126 this.rootCause = rootCause; 127 } 128 129 138 public OpenEJBException(String message, Throwable rootCause) { 139 this( message ); 140 this.rootCause = rootCause; 141 } 142 143 152 public String getMessage() { 153 if (rootCause != null) { 154 return super.getMessage() + ": " + rootCause.getMessage(); 155 } else { 156 return super.getMessage(); 157 } 158 } 159 160 167 public void printStackTrace() { 168 super.printStackTrace(); 169 if (rootCause != null) { 170 System.err.println("Root cause: "); 171 rootCause.printStackTrace(); 172 } 173 } 174 175 184 public void printStackTrace(PrintStream stream) { 185 super.printStackTrace(stream); 186 if (rootCause != null) { 187 stream.print("Root cause: "); 188 rootCause.printStackTrace(stream); 189 } 190 } 191 192 201 public void printStackTrace(PrintWriter writer) { 202 super.printStackTrace(writer); 203 if (rootCause != null) { 204 writer.print("Root cause: "); 205 rootCause.printStackTrace(writer); 206 } 207 } 208 209 217 public Throwable getRootCause() { 218 return rootCause; 219 } 220 221 } 222 | Popular Tags |