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

Document which exceptions request() might raise #6653

Open
mjperrone opened this issue Feb 27, 2024 · 2 comments
Open

Document which exceptions request() might raise #6653

mjperrone opened this issue Feb 27, 2024 · 2 comments

Comments

@mjperrone
Copy link

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.

@alain-khalil
Copy link

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.

@codespearhead
Copy link

codespearhead commented Mar 18, 2024

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.

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

3 participants