-
Notifications
You must be signed in to change notification settings - Fork 2
Description
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.