View Javadoc
1 2 package net.sf.voruta; 3 4 /*** 5 * 6 * @author baliuka 7 */ 8 public class DbException extends java.lang.RuntimeException { 9 10 private static boolean CHAINED; 11 static { 12 13 try{ 14 //HACK: 15 Throwable.class.getMethod("getCause", new Class[]{}); 16 CHAINED = false ; 17 18 }catch(Throwable t){ 19 20 CHAINED = true; 21 } 22 23 } 24 25 private Throwable cause; 26 /*** 27 * Creates a new instance of <code>DbException</code> without detail message. 28 */ 29 public DbException(Throwable cause) { 30 super(cause.getMessage()); 31 this.cause = cause; 32 } 33 34 35 /*** 36 * Constructs an instance of <code>DbException</code> with the specified detail message. 37 * @param msg the detail message. 38 */ 39 public DbException(String msg, Throwable cause) { 40 super(msg); 41 this.cause = cause; 42 } 43 /*** 44 * Constructs an instance of <code>DbException</code> with the specified detail message. 45 * @param msg the detail message. 46 */ 47 48 public DbException(String msg) { 49 super(msg); 50 51 } 52 53 public DbException() { 54 super(); 55 56 } 57 58 59 public Throwable getCause(){ 60 61 return cause; 62 63 } 64 65 66 67 public void printStackTrace(java.io.PrintWriter ps){ 68 69 super.printStackTrace(ps); 70 71 if(CHAINED){ 72 73 Throwable t = getCause(); 74 75 76 if( t != null ){ 77 78 ps.println("Caused by:"); 79 80 if(t instanceof java.sql.SQLException ){ 81 82 DbUtils.printStackTrace( (java.sql.SQLException)t, ps); 83 84 }else { 85 t.printStackTrace(ps); 86 } 87 } 88 } 89 90 } 91 92 public void printStackTrace(java.io.PrintStream printStream) { 93 java.io.PrintWriter pw = new java.io.PrintWriter(printStream); 94 printStackTrace(pw); 95 pw.flush(); 96 } 97 98 public void printStackTrace() { 99 printStackTrace(System.err); 100 } 101 102 103 }

This page was automatically generated by Maven