Skip to content

Conversation

@pgulley
Copy link
Member

@pgulley pgulley commented Oct 22, 2025

Small fix, addresses #98, and supercedes #108

@pgulley pgulley requested a review from philbudne October 22, 2025 16:52
raise RuntimeError(f"API Server Error {r.status_code}. Params: {params}")
if r.status_code != 200:
message = r.json()["note"]
raise RuntimeError(f"API Server Error {r.status_code}. MESSAGE: {message}. PARAMS: {params}")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe a subclass like this:

class APIErrorResponse(RuntimeError):
    def __init__(self, response, params, data):
        self.response = response
        self.params = params
        self.data = data
        super().__init__(f"API Server Error {response.status_code}. MESSAGE: {data.get('note')}. PARAMS: {params}")

and call as raise APIErrorResponse(r, params, data) so that API users can catch exceptions at one place, and are able to dump out enough info for us to help them disgnose their issue?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, good call! done!

@pgulley pgulley requested a review from philbudne October 24, 2025 20:01
@pgulley pgulley merged commit 876939c into mediacloud:main Oct 27, 2025
0 of 2 checks passed
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.

2 participants