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

This reverts commit 80edfefdb1.
This commit is contained in:
2022-05-09 03:40:54 +09:00
parent 194f2bd2a5
commit fa5919aa1a
10 changed files with 14 additions and 24 deletions
+3 -13
View File
@@ -49,7 +49,7 @@ function getFriendlyErrorType($type)
return "{$type}";
}
function getExceptionTraceAsString(\Throwable $exception)
function getExceptionTraceAsString($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)
function logErrorByCustomHandler(int $errno, string $errstr, string $errfile, int $errline, array $errcontext=null)
{
if (!(error_reporting() & $errno)) {
// This error code is not included in error_reporting, so let it fall
@@ -172,17 +172,7 @@ 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);
}
}
+2 -2
View File
@@ -363,7 +363,7 @@ function setGeneralCommand(int $generalID, array $rawTurnList, string $command,
'target'=>'arg'
];
}
catch (\Throwable $e){
catch (\Exception $e){
return [
'result'=>false,
'reason'=>$e->getCode().$e->getMessage(),
@@ -445,7 +445,7 @@ function setNationCommand(int $generalID, array $turnList, string $command, ?arr
'target'=>'arg'
];
}
catch (\Throwable $e){
catch (\Exception $e){
return [
'result'=>false,
'reason'=>$e->getCode().$e->getMessage(),
+1 -1
View File
@@ -38,7 +38,7 @@ if(count($lastMsgGet) >= 10){
}
array_shift($lastMsgGet);
}
catch(\Throwable $e){
catch(\Exception $e){
$lastMsgGet = [];
}
}
+1 -1
View File
@@ -24,7 +24,7 @@ if(count($lastMsgGet) >= 10){
}
array_shift($lastMsgGet);
}
catch(\Throwable $e){
catch(\Exception $e){
$lastMsgGet = [];
}
}
+1 -1
View File
@@ -35,7 +35,7 @@ if($eventArgsJson !== null){
$eventArgs[] = $eventNextArgs;
}
}
catch(\Throwable $e){
catch(\Exception $e){
Json::die([
'result'=>false,
'reason'=>'arg가 올바른 json이 아닙니다'
@@ -23,7 +23,7 @@ class FinishNationBetting extends \sammo\Event\Action
try {
$bettingHelper = new Betting($this->bettingID);
} catch (\Throwable $e) {
} catch (\Exception $e) {
return [__CLASS__, false, $e->getMessage()];
}
+1 -1
View File
@@ -392,7 +392,7 @@ class Scenario{
$text = \file_get_contents(ServConfig::getSharedIconPath('../hook/list.json?1'));
$storedIcons = Json::decode($text);
}
catch(\Throwable $e){
catch(\Exception $e){
$storedIcons = [];
}
+2 -2
View File
@@ -134,7 +134,7 @@ class GeneralBuilder{
$this->specialDomestic = SpecialityHelper::getDomesticClassByName($special);
$this->specialWar = GameConst::$defaultSpecialWar;
}
catch (\Throwable $e){
catch (\Exception $e){
$this->specialDomestic = GameConst::$defaultSpecialDomestic;
$this->specialWar = SpecialityHelper::getWarClassByName($special);
}
@@ -540,7 +540,7 @@ class GeneralBuilder{
$text = \file_get_contents(\sammo\ServConfig::getSharedIconPath('../hook/list.json?1'));
$storedIcons = \sammo\Json::decode($text);
}
catch(\Throwable $e){
catch(\Exception $e){
$storedIcons = [];
}
+1 -1
View File
@@ -345,7 +345,7 @@ if ($server == $baseServerName) {
$imgResult = false;
$imgDetail = $pullResult['reason'];
}
} catch (\Throwable $e) {
} catch (\Exception $e) {
$imgResult = false;
$imgDetail = $e->getMessage();
}
+1 -1
View File
@@ -15,7 +15,7 @@ class APIHelper
try {
$rawInput = file_get_contents('php://input');
$input = Json::decode($rawInput);
} catch (\Throwable $e) {
} catch (\Exception $e) {
Json::dieWithReason($e->getMessage());
$input = null;
}