From cfcdc3149f456877bef18cb8aef657e14e4e16ee Mon Sep 17 00:00:00 2001 From: Hide_D Date: Mon, 9 May 2022 22:31:14 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20logExceptionByCustomHandler=EC=97=90?= =?UTF-8?q?=EC=84=9C=20echo=20=EC=95=88=ED=95=98=EB=8A=94=20=EC=98=B5?= =?UTF-8?q?=EC=85=98=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- f_config/config.php | 11 +++++++---- src/sammo/APIHelper.php | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/f_config/config.php b/f_config/config.php index 3a5442d7..0a2d3ebf 100644 --- a/f_config/config.php +++ b/f_config/config.php @@ -96,7 +96,7 @@ function logError(string $err, string $errstr, string $errpath, array $trace) $fdb = FileDB::db(ROOT . '/d_log/err_log.sqlite3', ROOT . '/f_install/sql/err_log.sql'); $date = date("Ymd_His"); - $err = str_replace(ROOT, '{ROOT}', $errpath); + $err =str_replace(ROOT, '{ROOT}', $errpath); $errpath = str_replace(ROOT, '{ROOT}', $errpath); $trace = array_map(function (string $text) { return str_replace(ROOT, '{ROOT}', $text); @@ -139,7 +139,7 @@ function logErrorByCustomHandler(int $errno, string $errstr, string $errfile, in set_error_handler("\\sammo\\logErrorByCustomHandler"); -function logExceptionByCustomHandler(\Throwable $e) +function logExceptionByCustomHandler(\Throwable $e, bool $withDie = true) { logError( @@ -149,8 +149,11 @@ function logExceptionByCustomHandler(\Throwable $e) getExceptionTraceAsString($e) ); - echo $e->getTraceAsString(); - throw $e; + if($withDie){ + echo $e->getTraceAsString(); + + throw $e; + } } set_exception_handler('\\sammo\\logExceptionByCustomHandler'); diff --git a/src/sammo/APIHelper.php b/src/sammo/APIHelper.php index c549b7e7..2b74f7e4 100644 --- a/src/sammo/APIHelper.php +++ b/src/sammo/APIHelper.php @@ -100,7 +100,7 @@ class APIHelper } catch (\Exception $e) { Json::dieWithReason($e->getMessage()); } catch (\Throwable $e) { - logExceptionByCustomHandler($e); + logExceptionByCustomHandler($e, false); Json::dieWithReason($e->getMessage()); } catch (mixed $e) { Json::dieWithReason(strval($e));