1 package dynaop.util; 2 3 import java.io.*; 4 5 10 public class NestedException extends RuntimeException { 11 12 13 public static RuntimeException wrap(Throwable t) { 14 if (t instanceof RuntimeException ) return (RuntimeException ) t; 15 return new NestedException(t); 16 } 17 18 Throwable throwable; 19 20 21 NestedException(Throwable t) { 22 super(); 23 this.throwable = t; 24 } 25 26 public String toString() { 27 return this.getMessage(); 28 } 29 30 public String getMessage() { 31 return this.throwable.getMessage(); 32 } 33 34 public void printStackTrace() { 35 this.throwable.printStackTrace(); 36 } 37 38 public void printStackTrace(PrintStream out) { 39 this.throwable.printStackTrace(out); 40 } 41 42 public void printStackTrace(PrintWriter out) { 43 this.throwable.printStackTrace(out); 44 } 45 46 public Throwable getNested() { 47 return throwable; 48 } 49 } 50 | Popular Tags |