Class HttpRequestErrorContext
- Namespace
- Kampute.HttpClient
- Assembly
- Kampute.HttpClient.dll
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
-
HttpRequestErrorContext
- Derived
- Inherited Members
Constructors
HttpRequestErrorContext(HttpRestClient, HttpRequestMessage, HttpRequestException)
Initializes an instance of the HttpRequestErrorContext class.
public HttpRequestErrorContext(HttpRestClient client, HttpRequestMessage request, HttpRequestException error)
Parameters
clientHttpRestClientThe HttpRestClient instance used to send the request.
requestHttpRequestMessageThe HttpRequestMessage that resulted in a failure.
errorHttpRequestExceptionThe Exception containing details of the error encountered during the HTTP request.
Exceptions
- ArgumentNullException
Thrown if
client,requestorerroror 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
schedulerFactoryFunc<HttpRequestErrorContext, IRetryScheduler>A function that returns an IRetryScheduler for scheduling retry attempts based on the error context.
cancellationTokenCancellationTokenA 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
schedulerFactoryis null.