Raise errors when the GDELT API returns a non-200 status code#66
Merged
alex9smith merged 2 commits intomainfrom Apr 3, 2025
Merged
Raise errors when the GDELT API returns a non-200 status code#66alex9smith merged 2 commits intomainfrom
alex9smith merged 2 commits intomainfrom
Conversation
These are all subclasses of `requests.HTTPError` so consumers can either choose to catch all of them by catching that base class or individually based on their needs for eg. retries.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Raise a more specific error when the GDELT API returns a non-200 status code.
This adds several new custom error classes based on the most frequent non-200 response status codes. All of these are subclasses of the
requests.HTTPErrorwhich means consumers can either choose to catch that type of error and handle all response errors, or catch each individual type.This allows users of this library to define their own error handling and retry logic. For example, now you could choose to wait and retry a
RateLimitErrorbut not catch aBadRequestErrorto highlight a non-working query.Closes #64