Skip to content

Commit e08d115

Browse files
committed
output a better error
Signed-off-by: Robert Landers <landers.robert@gmail.com>
1 parent 7858ac2 commit e08d115

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/RemoteOrchestrationClient.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@
3535
use Bottledcode\DurablePhp\State\Status;
3636
use Exception;
3737
use Generator;
38+
use JsonException;
3839
use Override;
40+
use RuntimeException;
3941
use Withinboredom\Time\Unit;
4042

4143
use function Withinboredom\Time\Hours;
@@ -94,7 +96,11 @@ public function getStatus(OrchestrationInstance $instance): Status
9496
while ($result->getBody()->isReadable()) {
9597
$body .= $result->getBody()->buffer();
9698
}
97-
$result = json_decode($body, true, 512, JSON_THROW_ON_ERROR);
99+
try {
100+
$result = json_decode($body, true, flags: JSON_THROW_ON_ERROR);
101+
} catch (JsonException $exception) {
102+
throw new RuntimeException('Failed to decode JSON: ' . $body, previous: $exception);
103+
}
98104

99105
return Serializer::deserialize($result, Status::class);
100106
}

0 commit comments

Comments
 (0)