1 4 package gnu.mapping; 5 6 9 10 public class WrappedException extends RuntimeException 11 { 12 15 public WrappedException () 16 { 17 } 18 19 24 public WrappedException (String message) 25 { 26 super(message); 27 } 28 29 38 public WrappedException (Throwable e) 39 { 40 this(e.toString(), e); 41 } 42 43 52 public WrappedException (String message, Throwable e) 53 { 54 55 super(message, e); 56 57 60 } 61 62 67 public Throwable getException () 68 { 69 return getCause(); 70 } 71 72 77 public String toString () 78 { 79 return getMessage(); 80 } 81 82 84 90 95 97 98 99 public static RuntimeException wrapIfNeeded (Throwable ex) 100 { 101 if (ex instanceof RuntimeException ) 102 return (RuntimeException ) ex; 103 else 104 return new WrappedException(ex); 105 } 106 } 107 | Popular Tags |