Skip to content

Improve handling of API response with error message #89

Closed
@rsyring

Description

@rsyring

Enhancement description

The functions in http_requests should be improved so that error details returned in the API response are preserved.

The problem it solves

Currently, the functions in http_requests use response.raise_for_status() which throws a generic exception based on the HTTP response code. An error response from the API server can include additional details about why the request failed. For example, "At least one of supported fields should be set and non-empty" was stored in response.content for a recent API call I made that failed. But the exception was a generic 400 response exception and I had to make changes to the http_requests function to figure out what the real error was.

Alternatives

Catching the generic exceptions and logging the content. But since there is no one single entry point or method that can be overridden, it has to be done in multiple places, which is verbose. The best place to do it would be in http_requests.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions