Table of Contents

Class HttpResponseErrorContext

Namespace
Kampute.HttpClient
Assembly
Kampute.HttpClient.dll

Represents the context of an HTTP response error, providing information about the HTTP request, the client that sent the request, the error encountered, and the response that indicates failure.

public class HttpResponseErrorContext : HttpRequestErrorContext
Inheritance
HttpResponseErrorContext
Inherited Members

Constructors

HttpResponseErrorContext(HttpRestClient, HttpRequestMessage, HttpResponseMessage, HttpResponseException)

Initializes an instance of the HttpResponseErrorContext class.

public HttpResponseErrorContext(HttpRestClient client, HttpRequestMessage request, HttpResponseMessage response, HttpResponseException error)

Parameters

client HttpRestClient

The HttpRestClient instance used to send the request.

request HttpRequestMessage

The HttpRequestMessage that resulted in a failure.

response HttpResponseMessage

The HttpResponseMessage indicating the failure.

error HttpResponseException

The Exception containing details of the error encountered during the HTTP request.

Exceptions

ArgumentNullException

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

Properties

Error

Gets the HttpResponseException containing details of the HTTP response error.

public HttpResponseException Error { get; }

Property Value

HttpResponseException

The HttpResponseException containing details of the HTTP response error.

Response

Gets the HttpResponseMessage indicating the failure.

public HttpResponseMessage Response { get; }

Property Value

HttpResponseMessage

The HttpResponseMessage indicating the failure.

Methods

ScheduleRetryAsync(Func<HttpResponseErrorContext, IRetryScheduler?>, CancellationToken)

Schedules a retry for the failed HTTP request using a provided scheduler factory.

public Task<HttpErrorHandlerResult> ScheduleRetryAsync(Func<HttpResponseErrorContext, IRetryScheduler?> schedulerFactory, CancellationToken cancellationToken = default)

Parameters

schedulerFactory Func<HttpResponseErrorContext, IRetryScheduler>

A function that returns an IRetryScheduler for scheduling retry attempts based on the error context.

cancellationToken CancellationToken

A token that can be used to cancel the operation.

Returns

Task<HttpErrorHandlerResult>

A task that resolves to an HttpErrorHandlerResult indicating whether a retry should be attempted.

Exceptions

ArgumentNullException

Thrown if the schedulerFactory is null.