refac: 에러 핸들링 방식 변경, FatalError 대응

This commit is contained in:
2022-05-09 03:39:30 +09:00
parent 0ae6584b02
commit 194f2bd2a5
10 changed files with 24 additions and 14 deletions
+13 -3
View File
@@ -49,7 +49,7 @@ function getFriendlyErrorType($type)
return "{$type}";
}
function getExceptionTraceAsString($exception)
function getExceptionTraceAsString(\Throwable $exception)
{
//https://gist.github.com/abtris/1437966
$rtn = "";
@@ -117,7 +117,7 @@ function logError(string $err, string $errstr, string $errpath, array $trace)
]);
}
function logErrorByCustomHandler(int $errno, string $errstr, string $errfile, int $errline, array $errcontext=null)
function logErrorByCustomHandler(int $errno, string $errstr, string $errfile, int $errline)
{
if (!(error_reporting() & $errno)) {
// This error code is not included in error_reporting, so let it fall
@@ -172,7 +172,17 @@ function getAPIExecutorClass($path){
throw new \InvalidArgumentException("{$path}는 올바른 API 경로가 아님");
}
function checkForFatal()
{
$error = error_get_last();
if ( $error["type"] == E_ERROR ){
logErrorByCustomHandler( $error["type"], $error["message"], $error["file"], $error["line"] );
}
}
register_shutdown_function("\\sammo\\checkForFatal" );
function buildAPIExecutorClass($type, string $rootPath, array $args):\sammo\BaseAPI{
$class = getAPIExecutorClass($type);
return new $class($rootPath, $args);
}
}