Refit.ApiException
Represents an error that occurred after a response was received from the server.
Gets or sets the HTTP response content as a string.
Gets the HTTP response content headers as defined in RFC 2616.
Gets a value indicating whether the response has content.
Gets the HTTP response headers.
Gets the reason phrase which typically is sent by the server together with the status code.
Gets the HTTP response status code.
protected ApiException(HttpRequestMessage message, HttpMethod httpMethod, string content, HttpStatusCode statusCode, string reasonPhrase, HttpResponseHeaders headers, RefitSettings refitSettings)
Initializes a new instance of the ApiException class.
protected ApiException(HttpRequestMessage message, HttpMethod httpMethod, string content, HttpStatusCode statusCode, string reasonPhrase, HttpResponseHeaders headers, RefitSettings refitSettings, Exception innerException)
Initializes a new instance of the ApiException class.
protected ApiException(string exceptionMessage, HttpRequestMessage message, HttpMethod httpMethod, string content, HttpStatusCode statusCode, string reasonPhrase, HttpResponseHeaders headers, RefitSettings refitSettings)
Initializes a new instance of the ApiException class.
protected ApiException(string exceptionMessage, HttpRequestMessage message, HttpMethod httpMethod, string content, HttpStatusCode statusCode, string reasonPhrase, HttpResponseHeaders headers, RefitSettings refitSettings, Exception innerException)
Initializes a new instance of the ApiException class.
public static Task<ApiException> Create(HttpRequestMessage message, HttpMethod httpMethod, HttpResponseMessage response, RefitSettings refitSettings)
Create an instance of ApiException.
public static Task<ApiException> Create(HttpRequestMessage message, HttpMethod httpMethod, HttpResponseMessage response, RefitSettings refitSettings, Exception innerException)
Create an instance of ApiException.
public static Task<ApiException> Create(string exceptionMessage, HttpRequestMessage message, HttpMethod httpMethod, HttpResponseMessage response, RefitSettings refitSettings)
Create an instance of ApiException with a custom exception message.
public static Task<ApiException> Create(string exceptionMessage, HttpRequestMessage message, HttpMethod httpMethod, HttpResponseMessage response, RefitSettings refitSettings, Exception innerException)
Create an instance of ApiException with a custom exception message.
Synchronously deserializes the buffered response content as T. The content is already
a string, so this can run inside an exception filter where awaiting is not allowed by the CLR.
Get the deserialized response content as nullable T.
Attempts to synchronously deserialize the buffered response content as T without
throwing, making it usable from an exception filter:
catch (ApiException ex) when (ex.TryGetContentAs<Error>(out var error)).