Created
May 14, 2010 02:30
-
-
Save bendlas/400739 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.*; | |
class ExceptionAdapter extends RuntimeException { | |
private final String stackTrace; | |
public Exception originalException; | |
public ExceptionAdapter(Exception e) { | |
super(e.toString()); | |
originalException = e; | |
StringWriter sw = new StringWriter(); | |
e.printStackTrace(new PrintWriter(sw)); | |
stackTrace = sw.toString(); | |
} | |
public void printStackTrace() { | |
printStackTrace(System.err); | |
} | |
public void printStackTrace(java.io.PrintStream s) { | |
synchronized(s) { | |
s.print(getClass().getName() + ": "); | |
s.print(stackTrace); | |
} | |
} | |
public void printStackTrace(java.io.PrintWriter s) { | |
synchronized(s) { | |
s.print(getClass().getName() + ": "); | |
s.print(stackTrace); | |
} | |
} | |
public void rethrow() { throw originalException; } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment