1 16 package org.apache.commons.lang.exception; 17 18 import java.io.PrintStream ; 19 import java.io.PrintWriter ; 20 21 89 public class NestableException extends Exception implements Nestable { 90 91 95 protected NestableDelegate delegate = new NestableDelegate(this); 96 97 101 private Throwable cause = null; 102 103 107 public NestableException() { 108 super(); 109 } 110 111 117 public NestableException(String msg) { 118 super(msg); 119 } 120 121 128 public NestableException(Throwable cause) { 129 super(); 130 this.cause = cause; 131 } 132 133 141 public NestableException(String msg, Throwable cause) { 142 super(msg); 143 this.cause = cause; 144 } 145 146 public Throwable getCause() { 147 return cause; 148 } 149 150 157 public String getMessage() { 158 if (super.getMessage() != null) { 159 return super.getMessage(); 160 } else if (cause != null) { 161 return cause.toString(); 162 } else { 163 return null; 164 } 165 } 166 167 public String getMessage(int index) { 168 if (index == 0) { 169 return super.getMessage(); 170 } else { 171 return delegate.getMessage(index); 172 } 173 } 174 175 public String [] getMessages() { 176 return delegate.getMessages(); 177 } 178 179 public Throwable getThrowable(int index) { 180 return delegate.getThrowable(index); 181 } 182 183 public int getThrowableCount() { 184 return delegate.getThrowableCount(); 185 } 186 187 public Throwable [] getThrowables() { 188 return delegate.getThrowables(); 189 } 190 191 public int indexOfThrowable(Class type) { 192 return delegate.indexOfThrowable(type, 0); 193 } 194 195 public int indexOfThrowable(Class type, int fromIndex) { 196 return delegate.indexOfThrowable(type, fromIndex); 197 } 198 199 public void printStackTrace() { 200 delegate.printStackTrace(); 201 } 202 203 public void printStackTrace(PrintStream out) { 204 delegate.printStackTrace(out); 205 } 206 207 public void printStackTrace(PrintWriter out) { 208 delegate.printStackTrace(out); 209 } 210 211 public final void printPartialStackTrace(PrintWriter out) { 212 super.printStackTrace(out); 213 } 214 215 } 216 | Popular Tags |