requests icon indicating copy to clipboard operation
requests copied to clipboard

Document which exceptions request() might raise

Open mjperrone opened this issue 1 year ago • 3 comments
trafficstars

Ask to document which exceptions request() might raise

I notice that the .json function documents that it might raise a JSONDecodeError. This is very helpful for writing comprehensive error handling code around requests. I'm asking for that to be done for the main interface as well.

While a list of exceptions is provided in the documentation, it is not clear which exceptions will be returned by which methods. For example I don't think JSONDecodeError can be raised by .get. I tried to read the requests code to get a sense of which might be thrown from it, but it is a little challenging to follow as a first time reader.

mjperrone avatar Feb 27 '24 23:02 mjperrone

As a newcomer to this project, I'm eager to contribute and address the mentioned issue. I'd like to inquire about the exceptions list mentioned in the documentation—is it exhaustive and does it encompass all possible exceptions? If so, I'm prepared to work on enhancing the documentation. My proposal is to not only update the main interface but also extend the coverage to other methods, aiming for consistency similar to what is currently done for the .json() function.

alain-khalil avatar Mar 06 '24 11:03 alain-khalil

That would lead to a lot of code duplication in my opinion, apart from requests.ReadTimeout and requests.JSONDecodeError , all request methods return an instance of the Response object, which can raise the same exceptions.

codespearhead avatar Mar 18 '24 19:03 codespearhead

I want to solve this issue @mjperrone , if this issue is still opened and kindly assign me this issue and provide me necessary required information

29deepanshutyagi avatar Jun 07 '24 14:06 29deepanshutyagi