Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/Transporters/HttpTransporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,11 +172,13 @@ private function throwIfJsonError(ResponseInterface $response, string|ResponseIn
}

try {
/** @var array{error?: string|array{message: string|array<int, string>, type: string, code: string}} $data */
/** @var (array{error?: string|array{message: string|array<int, string>, type: string, code: string}})|(array{0?: array{error?: string|array{message: string|array<int, string>, code: string}}}) $data */
$data = json_decode($contents, true, flags: JSON_THROW_ON_ERROR);

if (isset($data['error'])) {
throw new ErrorException($data['error'], $response);
} elseif (isset($data[0]['error'])) {
throw new ErrorException($data[0]['error'], $response);
}
} catch (JsonException $jsonException) {
throw new UnserializableResponse($jsonException, $response);
Expand Down