From ffa7a2fc063abde69a8fbc3afe96e75b20323748 Mon Sep 17 00:00:00 2001 From: T2cc <5152438+gtguizhou@user.noreply.gitee.com> Date: Thu, 10 Jun 2021 14:07:58 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=99=E5=BC=82=E5=B8=B8=E5=87=BA=E6=9D=A5?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20try=20catch=20=E3=80=82=E9=98=B2=E6=AD=A2?= =?UTF-8?q?=E5=9C=A8=20report=20=E8=BF=87=E7=A8=8B=E4=B8=AD=E5=87=BA?= =?UTF-8?q?=E7=8E=B0=E5=BC=82=E5=B8=B8=EF=BC=8C=E5=AF=BC=E8=87=B4=E8=BF=9B?= =?UTF-8?q?=E7=A8=8B=E5=81=9C=E6=AD=A2=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Error.php | 55 ++++++++++++++++++++++++++++----------------------- 1 file changed, 30 insertions(+), 25 deletions(-) diff --git a/src/Error.php b/src/Error.php index 17b039b..f59a224 100644 --- a/src/Error.php +++ b/src/Error.php @@ -77,37 +77,42 @@ class Error */ public static function report($type, $exception) { - //标准化日志 - $text = Helper::formatException($exception, $type); + try { + //标准化日志 + $text = Helper::formatException($exception, $type); - //本地日志储存 - Helper::writeLog($text); + //本地日志储存 + Helper::writeLog($text); - //同步模式输出 - if (!Env::get('daemon')) echo($text); + //同步模式输出 + if (!Env::get('daemon')) echo($text); - //回调上报信息 - $notify = Env::get('notifyHand'); - if ($notify) - { - //闭包回调 - if ($notify instanceof Closure) + //回调上报信息 + $notify = Env::get('notifyHand'); + if ($notify) { - $notify($exception); - return; - } + //闭包回调 + if ($notify instanceof Closure) + { + $notify($exception); + return; + } - //Http回调 - $request = [ - 'errStr' => $exception->getMessage(), - 'errFile' => $exception->getFile(), - 'errLine' => $exception->getLine(), - ]; - $result = Helper::curl($notify, $request); - if (!$result || $result != 'success') - { - Helper::showError("request http api $notify failed", false, 'warring', true); + //Http回调 + $request = [ + 'errStr' => $exception->getMessage(), + 'errFile' => $exception->getFile(), + 'errLine' => $exception->getLine(), + ]; + $result = Helper::curl($notify, $request); + if (!$result || $result != 'success') + { + Helper::showError("request http api $notify failed", false, 'warring', true); + } } + }catch (\Throwable $e){ + echo $e->getMessage(); + echo "\r\n"; } } } \ No newline at end of file -- Gitee