HttpResponseErrorContext Class

Namespace
Kampute.HttpClient
Assembly
  • Kampute.HttpClient.dll

Definition

Describes an error response to the error handlers that decide whether to retry the request: the client, the request, the response, and the error.
public class HttpResponseErrorContext : HttpRequestErrorContext
Inheritance

Constructors

HttpResponseErrorContext(HttpRestClient, HttpRequestMessage, HttpResponseMessage, HttpResponseException, HttpRetryState)

Initializes a new instance of the HttpResponseErrorContext class.
public HttpResponseErrorContext(
	HttpRestClient client,
	HttpRequestMessage request,
	HttpResponseMessage response,
	HttpResponseException error,
	HttpRetryState retryState)

Parameters

client HttpRestClient
The client that sent the request.
request HttpRequestMessage
The request that received the error response.
response HttpResponseMessage
The error response.
error HttpResponseException
The exception for the error response.
retryState HttpRetryState
The retry state of the call that sent the request, shared by all its attempts.

Exceptions

ArgumentNullException
Thrown if client, request, response, error or retryState is null.

Properties

Error

Gets the exception for the error response.
public HttpResponseException Error { get; }

Property Value

HttpResponseException
The HttpResponseException that the client throws if no handler retries the request.

Response

Gets the error response.
public HttpResponseMessage Response { get; }

Property Value

HttpResponseMessage
The HttpResponseMessage with the error status code.

Methods

ScheduleRetryAsync(object, Func<HttpResponseErrorContext, IRetrySession>, CancellationToken)

Waits as the retry session of the source decides, and returns a clone of the request to retry, or a decision not to retry.
public Task<HttpErrorHandlerResult> ScheduleRetryAsync(object source, Func<HttpResponseErrorContext, IRetrySession> sessionFactory, CancellationToken cancellationToken = default)

Parameters

source object
The component that handles this kind of failure and counts its retries, typically the IHttpErrorHandler that handles the response.
sessionFactory Func<HttpResponseErrorContext, IRetrySession>
A function that creates the retry session of the source from this context, or returns null if the source does not retry.
cancellationToken CancellationToken optional
A token that can be used to cancel the operation.

Returns

Task<HttpErrorHandlerResult>
A task that resolves, after the wait, to a decision to retry with a clone of the request, or to HttpErrorHandlerResult.NoRetry.

Exceptions

ArgumentNullException
Thrown if source or sessionFactory is null.

Remarks