lyh
2025-06-25 d15e1f37f3b0518c1e5a181c5f9c70d34e9dd6a4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package org.jeecg.modules.mdc.util;
 
import java.io.PrintWriter;
import java.io.StringWriter;
 
/**
 * 异常工具
 *
 * @author: LiuS
 * @create: 2023-08-07 16:42
 */
public class ThrowableUtil {
 
    /**
     * 获取堆栈信息
     */
    public static String getStackTrace(Throwable throwable) {
        StringWriter sw = new StringWriter();
        try (PrintWriter pw = new PrintWriter(sw)) {
            throwable.printStackTrace(pw);
            return sw.toString();
        }
    }
 
}