-
Notifications
You must be signed in to change notification settings - Fork 37
Open
Description
The following code in makeRequest will discard the error information in a call
private function makeRequest($resource, $arguments, $method)
{
try {
$options = $this->getOptions($method, $arguments);
$response = $this->client->{$method}($this->endpoint . $resource, $options);
$collection = new Collection(
json_decode($response->getBody())
);
if ($collection->count() == 1) {
return $collection->collapse();
}
return $collection;
} catch (ClientException $e) {
throw new Exception($e->getResponse()->getBody());
} catch (RequestException $e) {
$response = $e->getResponse();
if ($response instanceof ResponseInterface) {
throw new Exception($e->getResponse()->getBody());
}
throw new Exception($e->getMessage());
}
}
Since you discard the info that ClientException contains we cannot see what kind of Error mailchimp throws. For instance we need to create a customer if it does not exist, which we need to check if the response status is 404.
The PUT method is not enough here since it will throw if the email has changed.
Is it possible to expose the raw ClientException here instead of discarding it (i.e. throw $e) or what is the reasoning about doing this?
Metadata
Metadata
Assignees
Labels
No labels