Skip to content

Commit

Permalink
Skin: Correctly handle errors produced by commented JSON decoder
Browse files Browse the repository at this point in the history
  • Loading branch information
dktapps committed Aug 16, 2022
1 parent 8fb7fff commit c9626c6
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/entity/Skin.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
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;

Expand Down Expand Up @@ -68,9 +67,10 @@ public function __construct(string $skinId, string $skinData, string $capeData =
}

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

/*
Expand Down

0 comments on commit c9626c6

Please sign in to comment.