/**
* 获取exception详情信息
*
* @param e
* Excetipn type
* @return String type
*/
public static String getExceptionDetail(Exception e) {
StringBuffer msg = new StringBuffer("null");
if (e != null) {
msg = new StringBuffer("");
String message = e.toString();
int length = e.getStackTrace().length;
if (length > 0) {
msg.append(message + "\n");
for (int i = 0; i < length; i++) {
msg.append("\t" + e.getStackTrace()[i] + "\n");
}
} else {
msg.append(message);
}
}
return msg.toString();
}
本文介绍了一个用于获取Java异常详细信息的方法。该方法通过遍历异常堆栈跟踪来构建异常详情字符串,包括异常类型、消息及调用堆栈信息。
693

被折叠的 条评论
为什么被折叠?



