-
Notifications
You must be signed in to change notification settings - Fork 97
Closed
Description
Usually errors 4XX have useful explanation about an occurred error, but the library does parse and return error body only if error code is < 400.
See ApiResource line 194.
I think it's better to do something like
// Handle 4XX responses, 5XX responses will throw an HttpAdapterException
if ($statusCode < 500) {
$body = json_decode($response->getBody()->getContents(), true);
if ($statusCode < 400) {
return $body;
} elseif ($statusCode === 404) {
throw new APIResponseException('The specified resource does not exist', 404);
} else {
throw new APIResponseException('Received bad response from ' . ucfirst($this->endpoint) . ' API: '. $statusCode.', body:' . print_r($body));
}
}I'm ready to prepare a PR.
djagya
Metadata
Metadata
Assignees
Labels
No labels