fix: logExceptionByCustomHandler에서 echo 안하는 옵션 추가

This commit is contained in:
2022-05-09 22:31:14 +09:00
parent 717017fad5
commit cfcdc3149f
2 changed files with 8 additions and 5 deletions
+7 -4
View File
@@ -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');
+1 -1
View File
@@ -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));