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

RFC / WIP (do not merge): surface cURL errors #194

Merged
merged 2 commits into from
Feb 3, 2016

Conversation

Stelminator
Copy link
Contributor

This is a work in progress, but I wanted to get comments sooner rather than later, since this is mostly complete.

I have a couple use cases involved here:

  1. I have a need to detect different kinds of cURL errors from multi-requests, specifically CURLE_OPERATION_TIMEDOUT (28), since I have subrequests using timeouts. These currently manifest as 'requests.no_crlf_separator' due to nothing being returned from curl_multi_getcontent in request_multiple resulting in a parse error. These are detectable from the code in $done['code'], but none of this is exposed anywhere I can get to.
  2. I want to be able to capture the time when an error has finished, and have the code available there. I've added this as a separate hook to not break existing parse_response implementations, but I'm open to suggestions here.

Please take a look and tell me what you think.

*
* @var string
*/
protected $reason = 'The requested sharing could not be done because the library you use don't have that particular feature enabled. (Added in 7.23.0)';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need to handle apostrophes

@mishan
Copy link
Contributor

mishan commented Nov 10, 2015

Pretty cool otherwise 👍

@mishan
Copy link
Contributor

mishan commented Nov 10, 2015

Class 'Requests_Exception_Transport_cURL_Easy' not found in /home/travis/build/rmccue/Requests/library/Requests/Transport/cURL.php on line 234

@Stelminator
Copy link
Contributor Author

yup, only "mostly" complete. Still looking at what I want that inheritance chain to look like.

@rmccue
Copy link
Collaborator

rmccue commented Nov 11, 2015

I'd think these should all be in a single exception class, Requests_Exception_Transport_cURL. Unlike HTTP errors, these are mostly an internal thing. If we can even get the same behaviour across both cURL and sockets, I'd be in favour of a single class there. (We can pass the raw error data including the cURL code itself through in the exception data.)

Generally though, I think the approach of using a separate hook is good here, and we should definitely be detecting the errors better than we do currently. Thanks for your work on the PR so far 🌴

@rmccue
Copy link
Collaborator

rmccue commented Nov 11, 2015

If we can even get the same behaviour across both cURL and sockets, I'd be in favour of a single class there.

Forgot to mention also: if we can get these consistent across both, I wouldn't be against generic Requests_Exception_Timeout/etc exceptions. It's just the internal cURL behaviour I don't want to expose.

@Stelminator
Copy link
Contributor Author

Ah, ok, yeah, as long as I can make a decision on how to handle the error code, I'd be in favor of fewer classes.

@Stelminator
Copy link
Contributor Author

I know this needs some whitespace cleanup, but I can't seem to get the tests to pass locally on master, so I'm not what is and what is not a legitimate failure.

@Stelminator
Copy link
Contributor Author

a bit cleaner now.

@Stelminator
Copy link
Contributor Author

working on fixing up the tests.

@Stelminator
Copy link
Contributor Author

ok, not sure what's up with those last two errors.

@Stelminator Stelminator force-pushed the PLAT-955 branch 2 times, most recently from dd90e15 to ec3f2b3 Compare December 9, 2015 23:29
@Stelminator
Copy link
Contributor Author

ok, please take a look at this version. I'm not sure why the tests are failing, but I don't see how the ones remaining could be due to my change. Earlier, I had messed up a merge/rebase, and so there were legitimate errors. seems like there's a network issue with the tests.

@rmccue
Copy link
Collaborator

rmccue commented Jan 31, 2016

Sorry for the delay here, had to work out why the tests were failing! Can you merge master into here please? :)


class Requests_Exception_Transport_cURL extends Requests_Exception_Transport {

const EASY = 'cURLEasy';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation needs to be tabs, not spaces.

@Stelminator Stelminator force-pushed the PLAT-955 branch 2 times, most recently from 3494d70 to 9f0d62d Compare February 2, 2016 21:14
implementation for cURL using new exception class
@Stelminator
Copy link
Contributor Author

Should be a bit cleaner now.

@rmccue
Copy link
Collaborator

rmccue commented Feb 3, 2016

Fantastic, thanks so much!

rmccue added a commit that referenced this pull request Feb 3, 2016
RFC / WIP (do not merge): surface cURL errors
@rmccue rmccue merged commit 25ee8f6 into WordPress:master Feb 3, 2016
@jrfnl jrfnl modified the milestones: 1.7.1, 1.7 Oct 18, 2020
@schlessera schlessera modified the milestones: 1.7, 1.8.0 Apr 17, 2021
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

Successfully merging this pull request may close these issues.

5 participants