HttpRequestErrorContext Class

Namespace
Kampute.HttpClient
Assembly
  • Kampute.HttpClient.dll

Definition

Represents the context of an HTTP request error, encapsulating details about the request, the error encountered, and the client that sent the request.
public class HttpRequestErrorContext
Inheritance
Inherited by

Constructors

HttpRequestErrorContext(HttpRestClient, HttpRequestMessage, HttpRequestException)

Initializes an instance of the HttpRequestErrorContext class.
public HttpRequestErrorContext(HttpRestClient client, HttpRequestMessage request, HttpRequestException error)

Parameters

client HttpRestClient
The HttpRestClient instance used to send the request.
request HttpRequestMessage
The HttpRequestMessage that resulted in a failure.
error HttpRequestException
The Exception containing details of the error encountered during the HTTP request.

Exceptions

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

Properties

Client

Gets the HttpRestClient instance used to send the request.
public HttpRestClient Client { get; }

Property Value

HttpRestClient
The HttpRestClient instance used to send the request.

Error

Gets the HttpRequestException containing details of the error encountered during the HTTP request.
public HttpRequestException Error { get; }

Property Value

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

Request

Gets the HttpRequestMessage that resulted in a failure.
public HttpRequestMessage Request { get; }

Property Value

HttpRequestMessage
The HttpRequestMessage that resulted in a failure.

Methods

ScheduleRetryAsync(Func<HttpRequestErrorContext, IRetryScheduler>, CancellationToken)

Schedules a retry for the failed HTTP request using a provided scheduler factory.
public Task<HttpErrorHandlerResult> ScheduleRetryAsync(Func<HttpRequestErrorContext, IRetryScheduler> schedulerFactory, CancellationToken cancellationToken = default)

Parameters

schedulerFactory Func<HttpRequestErrorContext, IRetryScheduler>
A function that returns an IRetryScheduler for scheduling retry attempts based on the error context.
cancellationToken CancellationToken optional
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.