php-http / httplug

HTTPlug, the HTTP client abstraction for PHP
http://httplug.io
MIT License
2.57k stars 39 forks source link

document when exception is thrown #82

Closed dbu closed 8 years ago

dbu commented 8 years ago

as discussed in https://github.com/php-http/documentation/pull/30/, we seem to only throw an exception when there is no response object available.

Exception in this case is more when connection or transfer, parsing failed. Here it transform response who was correctly received but has a status code between 400 and 599 (the status code list where it throws exception can be changed by configuring the plugin)

i guess that is what we agreed on, but if that is correct, we should update the phpdoc of Client to say when exceptions are thrown (basically if no response is available due to errors in the networking, or if the client decides to throw an exception for other reasons... maybe we should just mention the error plugin to make this more concrete. would that make sense?)

sagikazarmark commented 8 years ago

I would not bring the error plugin here. Otherwise, I agree.

joelwurtz commented 8 years ago

There may be case where you have an exception and a response, like you received all the status code and the headers, but connection was interrupted when receiving the body of the response. (So you have a response, which is incomplete, but can always be used for debugging purpose)

sagikazarmark commented 8 years ago

I would say in this case you don't have a response and should be a network error returned.

Longer answer: you cannot return a complete Response object.

dbu commented 8 years ago

i guess it depends on the client what kind of exception it throws in that case. but an exception must will be thrown as there won't be a HTTP status code in the response for this situation.

why not mention the error plugin?

sagikazarmark commented 8 years ago

Actually, I don't mind mentioning the error plugin, but it is some sort of coupling to an implementation which feels weird IMHO.

sagikazarmark commented 8 years ago

Can this be closed in favor of #87 ?