package dynaop.util;
import java.io.*;
/**
* Turns a nested exception into a runtime exception.
*
* @author Bob Lee (crazybob@crazybob.org)
*/
public class NestedException extends RuntimeException {
/** Wrap another exeception in a RuntimeException. */
public static RuntimeException wrap(Throwable t) {
if (t instanceof RuntimeException) return (RuntimeException) t;
return new NestedException(t);
}
Throwable throwable;
/** Wraps another exeception. */
NestedException(Throwable t) {
super();
this.throwable = t;
}
public String toString() {
return this.getMessage();
}
public String getMessage() {
return this.throwable.getMessage();
}
public void printStackTrace() {
this.throwable.printStackTrace();
}
public void printStackTrace(PrintStream out) {
this.throwable.printStackTrace(out);
}
public void printStackTrace(PrintWriter out) {
this.throwable.printStackTrace(out);
}
public Throwable getNested() {
return throwable;
}
}
|