Skip to content

Commit c9626c6

Browse files
committed
Skin: Correctly handle errors produced by commented JSON decoder
1 parent 8fb7fff commit c9626c6

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/entity/Skin.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
use function implode;
2929
use function in_array;
3030
use function json_encode;
31-
use function json_last_error_msg;
3231
use function strlen;
3332
use const JSON_THROW_ON_ERROR;
3433

@@ -68,9 +67,10 @@ public function __construct(string $skinId, string $skinData, string $capeData =
6867
}
6968

7069
if($geometryData !== ""){
71-
$decodedGeometry = (new CommentedJsonDecoder())->decode($geometryData);
72-
if($decodedGeometry === false){
73-
throw new InvalidSkinException("Invalid geometry data (" . json_last_error_msg() . ")");
70+
try{
71+
$decodedGeometry = (new CommentedJsonDecoder())->decode($geometryData);
72+
}catch(\RuntimeException $e){
73+
throw new InvalidSkinException("Invalid geometry data: " . $e->getMessage(), 0, $e);
7474
}
7575

7676
/*

0 commit comments

Comments
 (0)