xieb
2024-12-02 9f204e8842e1688858889a67b702d9e19bb18b15
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
package cn.gistack.by.nettyUpload.utils;
 
import java.io.PrintWriter;
import java.io.StringWriter;
 
public class ExceptionUtils {
    /**
     * 获取异常堆栈字符串。
     *
     * @param t {@link Throwable}
     * @return
     */
    public static String getStackString(Throwable t) {
        StringWriter sw  = new StringWriter();
        t.printStackTrace(new PrintWriter(sw, true));
        return  sw.getBuffer().toString();
    }
}