From c9626c610b8f6810c8c987559c9197b2a291f0bb Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Tue, 16 Aug 2022 17:22:56 +0100 Subject: [PATCH] Skin: Correctly handle errors produced by commented JSON decoder --- src/entity/Skin.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/entity/Skin.php b/src/entity/Skin.php index f10d72fc3..0cdfa1160 100644 --- a/src/entity/Skin.php +++ b/src/entity/Skin.php @@ -28,7 +28,6 @@ use pocketmine\utils\Limits; use function implode; use function in_array; use function json_encode; -use function json_last_error_msg; use function strlen; use const JSON_THROW_ON_ERROR; @@ -68,9 +67,10 @@ final class Skin{ } if($geometryData !== ""){ - $decodedGeometry = (new CommentedJsonDecoder())->decode($geometryData); - if($decodedGeometry === false){ - throw new InvalidSkinException("Invalid geometry data (" . json_last_error_msg() . ")"); + try{ + $decodedGeometry = (new CommentedJsonDecoder())->decode($geometryData); + }catch(\RuntimeException $e){ + throw new InvalidSkinException("Invalid geometry data: " . $e->getMessage(), 0, $e); } /*