Skip to content
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

Should have different error for empty response than error response #45

Closed
smvanbru opened this issue Mar 21, 2016 · 4 comments
Closed

Comments

@smvanbru
Copy link

At present, in Pinterest/Transport/Request.php, line 211-212, you raise an error for empty response with the same block of code as an error response. With that setup, the empty response is hard to identify in order to be handled appropriately in apps using this library. Would it be possible to adjust this bit to return an identifiable error code for empty responses? Thanks!

@dirkgroenen
Copy link
Owner

dirkgroenen commented May 6, 2016

I assume you're referring to the difference between a FALSE response from curl_exec compared to a curl_exec which returns with curl errors? In case you mean something like that I assume something like the following would help:

if ($response_data === false && !$ch->hasErrors()) {
    throw new CurlException("Error: Curl request failed")
}
else if($ch->hasErrors()) {
    throw new PinterestException('Error: execute() - cURL error: ' . $ch->getErrors(), $ch->getErrorNumber());
}

Let me know if the above is what you mean.

dirkgroenen added a commit that referenced this issue May 6, 2016
@smvanbru
Copy link
Author

smvanbru commented May 6, 2016

ya, that should do it. Thanks!

@dirkgroenen
Copy link
Owner

Cool, I've merged the changes into development. Shall be merged into master somewhere in the next few days.

@dirkgroenen
Copy link
Owner

Just released a new version which includes this fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants