Skip to content

Commit

Permalink
Add nullsafe checks for API response
Browse files Browse the repository at this point in the history
  • Loading branch information
SecondeJK committed Sep 24, 2024
1 parent b23db9b commit d5976fd
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/Messages/ExceptionErrorHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ public function __invoke(ResponseInterface $response, RequestInterface $request)
throw new ClientException\Server($responseBody['title'] . ': ' . $responseBody['detail']);
}

throw new ClientException\Request($responseBody['title'] . ': ' . $responseBody['detail']);
$message = $responseBody['title'] ?? '';

if (isset($responseBody['detail'])) {
$message .= ': ' . $responseBody['detail'];
}

throw new ClientException\Request($message);
}
}

0 comments on commit d5976fd

Please sign in to comment.