1 54 package org.hibernate.exception; 55 56 import java.io.PrintStream ; 57 import java.io.PrintWriter ; 58 59 71 public class NestableRuntimeException extends RuntimeException implements Nestable { 72 73 77 protected NestableDelegate delegate = new NestableDelegate( this ); 78 79 83 private Throwable cause = null; 84 85 89 public NestableRuntimeException() { 90 super(); 91 } 92 93 99 public NestableRuntimeException(String msg) { 100 super( msg ); 101 } 102 103 110 public NestableRuntimeException(Throwable cause) { 111 super(); 112 this.cause = cause; 113 } 114 115 123 public NestableRuntimeException(String msg, Throwable cause) { 124 super( msg ); 125 this.cause = cause; 126 } 127 128 public Throwable getCause() { 129 return cause; 130 } 131 132 137 public String getMessage() { 138 if ( super.getMessage() != null ) { 139 return super.getMessage(); 140 } 141 else if ( cause != null ) { 142 return cause.toString(); 143 } 144 else { 145 return null; 146 } 147 } 148 149 public String getMessage(int index) { 150 if ( index == 0 ) { 151 return super.getMessage(); 152 } 153 else { 154 return delegate.getMessage( index ); 155 } 156 } 157 158 public String [] getMessages() { 159 return delegate.getMessages(); 160 } 161 162 public Throwable getThrowable(int index) { 163 return delegate.getThrowable( index ); 164 } 165 166 public int getThrowableCount() { 167 return delegate.getThrowableCount(); 168 } 169 170 public Throwable [] getThrowables() { 171 return delegate.getThrowables(); 172 } 173 174 public int indexOfThrowable(Class type) { 175 return delegate.indexOfThrowable( type, 0 ); 176 } 177 178 public int indexOfThrowable(Class type, int fromIndex) { 179 return delegate.indexOfThrowable( type, fromIndex ); 180 } 181 182 public void printStackTrace() { 183 delegate.printStackTrace(); 184 } 185 186 public void printStackTrace(PrintStream out) { 187 delegate.printStackTrace( out ); 188 } 189 190 public void printStackTrace(PrintWriter out) { 191 delegate.printStackTrace( out ); 192 } 193 194 public final void printPartialStackTrace(PrintWriter out) { 195 super.printStackTrace( out ); 196 } 197 198 } 199 | Popular Tags |