-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
getStatusCode() exception #14
Comments
Hhm... That's strange. It seems that the response is not properly created into the guzzle event. How do you get this error? Which method are you calling so that I can try to reproduce the issue? |
Here's my versions:
I'm using |
But are you trying to use this listener yourself? It's not meant to be used by you. Only the client automatically register this listener. You should not subscribe yourself. What are you trying to do exactly? |
I'm not using the listener myself. My subscription code just broke for some reason with this exception. |
I've double checked the service descriptor and it seems right. Does it fail with other methods or only "subscribe" ? |
It looks like it's failing with other methods as well. |
Gosh. That's annoying. I checked the Guzzle change log and no BC seems to have been done. Can you try to forcing an older version of Guzzle into your composer.json (like 3.7)? I have not touched ZfrMailchimp so it's either a problem on MailChimp that caused the client to throw a strange exception, or a change in Guzzle (they have already done BC in minor version, that's annoying). |
This seems related to Guzzle: guzzle/guzzle#589 |
Are you using PHP 5.3.3 ? |
|
Grrr. Please try what I told you (testing with older version of guzzle) |
I've just tried to use Guzzle |
Wow. That's really strange. I cannot explain it to myself :'(. I'll try tomorrow if I can replicate the issue. |
@univate, as you seems to use ZfrMailChimp, did you encounter any issue? |
OK. Thank you @bakura10 for a quick reply as always. But, is it possible that something can interfere with Guzzle and/or ZfrMailChimp? Maybe another package or something? |
Hmmm I can't see exactly what could interfere :/. |
If you comment that line (https://github.com/zf-fr/zfr-mailchimp/blob/master/src/ZfrMailChimp/Client/MailChimpClient.php#L178), so that the subscriber is no longer attached, does it work or does it trigger another error? |
Gotcha!
How stupid of me. Looks like configuration file were reverted to default values and it caused to use incorrect API key. Sorry, I should have more properly checked my application logic first. Looks like I need a good sleep )) Maybe it is an opportunity to improve listener logic by the way? |
Ouf ! Good news. What do you want to improve about listener logic? Adding a test to check if the response exist ? I'm not sure this bring any improvement though. |
In this case it was hiding the real problem (original exception). Maybe there is a way to distinguish between MailChimp (domain related) errors vs. core one (cURL etc). I think ideally, it should detect errors from MailChimp and throw related exceptions. In other cases it should not alter behavior in any way. |
Ok. Can you inspect if the $event (https://github.com/zf-fr/zfr-mailchimp/blob/master/src/ZfrMailChimp/Client/Listener/ErrorHandlerListener.php#L143) contains an 'exception' property or something? What we could do is something like that : public function handleError(Event $event)
{
$response = $event['response'];
if ($response->getStatusCode() === 200) {
return;
}
$result = json_decode($response->getBody(), true);
$errorName = isset($result['name']) ? $result['name'] : null;
if (null === $errorName) {
// Not a MailChimp exception
return or throw $event['exception'];
}
throw new $this->errorMap[$errorName]($result['error'], $result['code']);
} I don't exactly remember how this object is formed. |
I will try to figure that out and submit a pull-request then ) |
I haven't come across this error - using the latest code here in production. I am not using the zfr-mailchimp-bundle, I am using an older version of guzzle - 3.7.4 |
Updated exception event listener to better represent desired logic and handle edge scenarios like encountered here: zf-fr#14
if async is set, response will be null, so #15 would fix it. |
Hi. Ok, I will do that now. |
Hey Michaël!
I'm getting this weird exception:
Can you elaborate please? Thanks!
The text was updated successfully, but these errors were encountered: