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
Add exception handling to docs #1082
Comments
Hey @mm326 , Thanks for suggesting an update to the docs! A pull request for the docs would be very welcome! My initial thought is to modify the except block to be more generic and just let the specific quota error message bubble up. I'd suggest to use For example,
I tried sample code from YouTube API Data v3 and sent a bunch of requests to exceed my YouTube quota limit to test the output of the proposed docs update. After the quota was exceeded, I ran the above code and found that Looking at the the error parsing code, the code is only looking for either
I managed to hack together some code to determine the best error detail keyword to use and then populate the Existing code
Improved code
Please let me know if you are intersted in opening a PR to improve the error parsing in the library! You would also need to add a unit test here. |
I've submitted a PR let me know what you think :) |
Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly: - [x] Make sure to open an issue as a [bug/issue](https://github.com/googleapis/google-api-python-client/issues/new/choose) before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea - [x] Ensure the tests and linter pass - [x] Code coverage does not decrease (if any source code was changed) - [x] Appropriate docs were updated (if necessary) Fixes #1082 🦕
🤖 I have created a release \*beep\* \*boop\* --- ### [1.12.6](https://www.github.com/googleapis/google-api-python-client/compare/v1.12.5...v1.12.6) (2020-11-16) ### Documentation * Change error parsing to check for 'message' ([#1083](https://www.github.com/googleapis/google-api-python-client/issues/1083)) ([a341c5a](https://www.github.com/googleapis/google-api-python-client/commit/a341c5a5e31ba16da109658127b58cb7e5dbeedd)), closes [#1082](https://www.github.com/googleapis/google-api-python-client/issues/1082) * Update oauth docs to include snippet to get email address of authenticated user ([#1088](https://www.github.com/googleapis/google-api-python-client/issues/1088)) ([25fba64](https://www.github.com/googleapis/google-api-python-client/commit/25fba648ea647b62f2a6edc54ae927c1ed381b45)), closes [#1071](https://www.github.com/googleapis/google-api-python-client/issues/1071) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please).
Hi :)
I was reading the docs looking for an example to handle exceptions from when request.execute() goes wrong e.g. a 403 due to
Exceeding qouta limits.
I would like for the docs to be updated with a try: and except: like this
or something else in the
except
blockIf you're happy with this I'd like to contribute this as a first timer to open source?
The text was updated successfully, but these errors were encountered: