自己实现
public static String getErrorInfoFromException(Exception e) {
try {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
e.printStackTrace(pw);
return "\r\n" + sw.toString() + "\r\n";
} catch (Exception e2) {
return "bad getErrorInfoFromException";
}
}
使用apache.commons.lang 包
String str = org.apache.commons.lang3.exception.ExceptionUtils.getStackTrace(Throwable);
网友评论