异常信息尝试获取
This commit is contained in:
@@ -3,6 +3,7 @@ package com.czg.utils;
|
||||
import cn.hutool.core.lang.func.Func0;
|
||||
import cn.hutool.core.thread.ThreadUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.core.NestedExceptionUtils;
|
||||
import org.springframework.transaction.support.TransactionSynchronization;
|
||||
import org.springframework.transaction.support.TransactionSynchronizationManager;
|
||||
|
||||
@@ -27,12 +28,17 @@ public class FunUtils {
|
||||
return value;
|
||||
}
|
||||
|
||||
public static void asyncSafeRunVoid(Runnable func, String... msg) {
|
||||
ThreadUtil.execAsync(() -> safeRunVoid(func, msg));
|
||||
}
|
||||
|
||||
|
||||
public static void safeRunVoid(Runnable func, String... msg) {
|
||||
try {
|
||||
func.run();
|
||||
} catch (Exception e) {
|
||||
log.error("方法执行失败: {}", msg, e);
|
||||
log.warn(msg.length > 0 ? msg[0] : "方法执行失败: {}", e.getMessage());
|
||||
String message = NestedExceptionUtils.getMostSpecificCause(e).getMessage();
|
||||
log.warn(msg.length > 0 ? msg[0] : "方法执行失败: {}", message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,10 +50,6 @@ public class FunUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public static void asyncSafeRunVoid(Runnable func, String... msg) {
|
||||
ThreadUtil.execAsync(() -> safeRunVoid(func, msg));
|
||||
}
|
||||
|
||||
/**
|
||||
* 在事务提交后执行方法
|
||||
* 异步 执行
|
||||
|
||||
Reference in New Issue
Block a user