This commit is contained in:
zimoyin
2026-04-02 17:42:00 +08:00
parent ac95dbb1c8
commit 4c841b9dbf
963 changed files with 347242 additions and 354 deletions
+24
View File
@@ -0,0 +1,24 @@
<?php
namespace plugin\admin\app\common;
use app\utils\Logger;
class ExUtil
{
/**
* 执行闭包,捕获异常并记录日志,不中断程序
* @param callable $func 要执行的逻辑
* @param string $errorMsg 异常日志描述
* @return mixed|null 执行结果 / 异常返回null
*/
public static function runCatching(callable $func, string $errorMsg = '执行异常'): mixed
{
try {
return $func();
} catch (\Throwable $e) {
Logger::error($errorMsg, $e);
return null;
}
}
}