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

How about a Pest_TimeoutException ? #28

Open
polesen opened this issue Dec 21, 2012 · 2 comments
Open

How about a Pest_TimeoutException ? #28

polesen opened this issue Dec 21, 2012 · 2 comments

Comments

@polesen
Copy link

polesen commented Dec 21, 2012

Currently, when I set curl timeout options, and a request through pest times out, a Pest_UnknownResponse will be throw. This is because the "http_code" in $meta is 0.

Would it be nice for Pest to support discovering timeouts as a special kind of error?

Currently, the exceptions thrown map to HTTP responses, and for a REST api, that seems to be as it should. But working with pest and timeouts require all pest calls to be wrapped in "Pest_UnknownResponse" catches, where each catch then tries to discover if request took more than timeout seconds.

What are your thoughts on this?

@zuk
Copy link
Member

zuk commented Jan 15, 2013

I think it's probably a good idea.

I should say though that (fortunately) I don't have to write much PHP nowadays, so maintaining Pest is a pretty low priority for me. I should probably look into getting someone to take over maintenance...

@ghost
Copy link

ghost commented Jun 13, 2013

Would be easy to add now if pull #42 gets merged.
With it CURLOPT_TIMEOUT sets curl_exec to fail and then you can catch Pest_Curl_Exec exception with curl_error() for timeout. I kind of wanted to limit this purely to errnos but existing library already was relying on error messages instead of errors so wanted to keep it consistent where supported (f.ex. PHP JSON has only later version support for error messages instead of pure errno's)

Could add this in next pull as separate exception though..? What speaks (just small little bit..) against this is the fact that we expose curl already directly settings wise (ugly IMHO) in non-documented manner (because people need it) so it would be more consistent to let the developer handle curl errors that we pass with the exception.. ?

Overall I kind of hate the processError() thing and could add processErrno($errno, $layer) instead e.g. processErrno(29, 'curl') would get timeout processed addition to exception perhaps... errnos are better as matches as well.. though separate exceptions are always best as long as you can keep up with them...

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