1 54 package org.hibernate.exception; 55 56 import java.io.PrintStream ; 57 import java.io.PrintWriter ; 58 59 127 public class NestableException extends Exception implements Nestable { 128 129 133 protected NestableDelegate delegate = new NestableDelegate( this ); 134 135 139 private Throwable cause = null; 140 141 145 public NestableException() { 146 super(); 147 } 148 149 155 public NestableException(String msg) { 156 super( msg ); 157 } 158 159 166 public NestableException(Throwable cause) { 167 super(); 168 this.cause = cause; 169 } 170 171 179 public NestableException(String msg, Throwable cause) { 180 super( msg ); 181 this.cause = cause; 182 } 183 184 public Throwable getCause() { 185 return cause; 186 } 187 188 193 public String getMessage() { 194 if ( super.getMessage() != null ) { 195 return super.getMessage(); 196 } 197 else if ( cause != null ) { 198 return cause.toString(); 199 } 200 else { 201 return null; 202 } 203 } 204 205 public String getMessage(int index) { 206 if ( index == 0 ) { 207 return super.getMessage(); 208 } 209 else { 210 return delegate.getMessage( index ); 211 } 212 } 213 214 public String [] getMessages() { 215 return delegate.getMessages(); 216 } 217 218 public Throwable getThrowable(int index) { 219 return delegate.getThrowable( index ); 220 } 221 222 public int getThrowableCount() { 223 return delegate.getThrowableCount(); 224 } 225 226 public Throwable [] getThrowables() { 227 return delegate.getThrowables(); 228 } 229 230 public int indexOfThrowable(Class type) { 231 return delegate.indexOfThrowable( type, 0 ); 232 } 233 234 public int indexOfThrowable(Class type, int fromIndex) { 235 return delegate.indexOfThrowable( type, fromIndex ); 236 } 237 238 public void printStackTrace() { 239 delegate.printStackTrace(); 240 } 241 242 public void printStackTrace(PrintStream out) { 243 delegate.printStackTrace( out ); 244 } 245 246 public void printStackTrace(PrintWriter out) { 247 delegate.printStackTrace( out ); 248 } 249 250 public final void printPartialStackTrace(PrintWriter out) { 251 super.printStackTrace( out ); 252 } 253 254 } 255 | Popular Tags |