package com.jx.ec.util;
import java.io.PrintWriter;
import java.io.StringWriter;
/**
* 处理日常 excetion
* @author Mr He
*
*/
public class ExceptionUtil {
public ExceptionUtil() {
super();
}
/**
* 处理 exception 具体到一行
* @param e 异常
* @return 异常字符串
*/
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";
}
}
/**
* 处理 exception 具体到一行
* @param e 异常
* @return 异常字符串
*/
public static String getException(Exception e) {
return getErrorInfoFromException(e);
}
}
exception工具类
最新推荐文章于 2024-10-02 06:14:56 发布