1 22 package org.jboss.util; 23 24 import java.io.PrintWriter ; 25 import java.io.PrintStream ; 26 27 import java.sql.SQLException ; 28 29 36 public class NestedSQLException 37 extends SQLException 38 implements NestedThrowable 39 { 40 41 protected final Throwable nested; 42 43 49 public NestedSQLException(final String msg) { 50 super(msg); 51 this.nested = null; 52 } 53 54 61 public NestedSQLException(final String msg, final Throwable nested) { 62 super(msg); 63 this.nested = nested; 64 NestedThrowable.Util.checkNested(this, nested); 65 } 66 67 73 public NestedSQLException(final Throwable nested) { 74 this(nested.getMessage(), nested); 75 } 76 77 83 public NestedSQLException(final String msg, final String state) { 84 super(msg, state); 85 this.nested = null; 86 } 87 88 95 public NestedSQLException(final String msg, final String state, final int code) { 96 super(msg, state, code); 97 this.nested = null; 98 } 99 100 105 public Throwable getNested() { 106 return nested; 107 } 108 109 116 public Throwable getCause() { 117 return nested; 118 } 119 120 125 public String getMessage() { 126 return NestedThrowable.Util.getMessage(super.getMessage(), nested); 127 } 128 129 135 public void printStackTrace(final PrintStream stream) { 136 if (nested == null || NestedThrowable.PARENT_TRACE_ENABLED) { 137 super.printStackTrace(stream); 138 } 139 NestedThrowable.Util.print(nested, stream); 140 } 141 142 148 public void printStackTrace(final PrintWriter writer) { 149 if (nested == null || NestedThrowable.PARENT_TRACE_ENABLED) { 150 super.printStackTrace(writer); 151 } 152 NestedThrowable.Util.print(nested, writer); 153 } 154 155 159 public void printStackTrace() { 160 printStackTrace(System.err); 161 } 162 } 163 | Popular Tags |