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
3 changed files with 8 additions and 9 deletions

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());