Skip to content

Raise errors when the GDELT API returns a non-200 status code#66

Merged
alex9smith merged 2 commits intomainfrom
raise-errors
Apr 3, 2025
Merged

Raise errors when the GDELT API returns a non-200 status code#66
alex9smith merged 2 commits intomainfrom
raise-errors

Conversation

@alex9smith
Copy link
Owner

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.HTTPError which 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 RateLimitError but not catch a BadRequestError to highlight a non-working query.

Closes #64

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.
@alex9smith alex9smith merged commit 818efc4 into main Apr 3, 2025
2 checks passed
@alex9smith alex9smith deleted the raise-errors branch April 3, 2025 08:58
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

Successfully merging this pull request may close these issues.

Raise errors when the GDELT API returns a non-200 status code

1 participant