Skip to content

Better Error Messages for Exceptions #6

@halforbit

Description

@halforbit

Today when an unexpected HTTP response code is encountered, ApiClient throws an ApiRequestException.

While this exception is rich with properties about the request and the response, if the server includes a text response body (often containing an error message), this is not easily surfaced. A work-around today is to catch the ApiRequestException and use its Response to get the text content, but we can probably do better.

Also, Response contains an ErrorMessage property that is only populated under some circumstances, and particularly not when an unexpected response code is encountered.

On an unexpected response code, let's try to interrogate the response body (if there is one) as text, and include that text in both the Message property of the exception as well as the ErrorMessage property.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions