MainLogger: do not assume that exception codes are always integers

PDOException most notably breaks this rule.
closes #4294
This commit is contained in:
Dylan K. Taylor 2021-07-05 19:20:59 +01:00
parent 1d8f0033af
commit b7ea10b905
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D
3 changed files with 8 additions and 9 deletions

View File

@ -44,6 +44,7 @@ use function fwrite;
use function get_loaded_extensions;
use function implode;
use function is_dir;
use function is_int;
use function is_resource;
use function json_encode;
use function json_last_error_msg;

View File

@ -28,6 +28,7 @@ use pocketmine\errorhandler\ErrorTypeToStringMap;
use pocketmine\thread\Thread;
use pocketmine\thread\Worker;
use function get_class;
use function is_int;
use function preg_replace;
use function sprintf;
use function trim;
@ -159,10 +160,12 @@ class MainLogger extends \AttachableThreadedLogger implements \BufferedLogger{
$errstr = preg_replace('/\s+/', ' ', trim($e->getMessage()));
$errno = $e->getCode();
try{
$errno = ErrorTypeToStringMap::get($errno);
}catch(\InvalidArgumentException $ex){
//pass
if(is_int($errno)){
try{
$errno = ErrorTypeToStringMap::get($errno);
}catch(\InvalidArgumentException $ex){
//pass
}
}
$errfile = Filesystem::cleanPath($e->getFile());

View File

@ -205,11 +205,6 @@ parameters:
count: 1
path: ../../../src/utils/Internet.php
-
message: "#^Parameter \\#1 \\$errorType of static method pocketmine\\\\errorhandler\\\\ErrorTypeToStringMap\\:\\:get\\(\\) expects int, mixed given\\.$#"
count: 1
path: ../../../src/utils/MainLogger.php
-
message: "#^Part \\$errno \\(mixed\\) of encapsed string cannot be cast to string\\.$#"
count: 1