Apply changes in FOSS because of prioprietary merges

This commit is contained in:
Kelven Yang 2011-04-01 14:13:17 -07:00
parent de2d650adf
commit f14be91167
1 changed files with 10 additions and 3 deletions

View File

@ -22,12 +22,19 @@ import java.io.StringWriter;
public class ExceptionUtil {
public static String toString(Throwable th) {
return toString(th, true);
}
public static String toString(Throwable th, boolean printStack) {
final StringWriter writer = new StringWriter();
writer.append("Exception: " + th.getClass().getName() + "\n");
writer.append("Message: ");
writer.append(th.getMessage());
writer.append("\n Stack: ");
th.printStackTrace(new PrintWriter(writer));
writer.append(th.getMessage()).append("\n");
if(printStack) {
writer.append("Stack: ");
th.printStackTrace(new PrintWriter(writer));
}
return writer.toString();
}
}