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
- object
- HttpRequestErrorContext
- Inherited by
Constructors
HttpRequestErrorContext(HttpRestClient, HttpRequestMessage, HttpRequestException)
Initializes an instance of the HttpRequestErrorContext class.
public HttpRequestErrorContext(HttpRestClient client, HttpRequestMessage request, HttpRequestException error)Parameters
clientHttpRestClient- The HttpRestClient instance used to send the request.
requestHttpRequestMessage- The HttpRequestMessage that resulted in a failure.
errorHttpRequestException- The Exception containing details of the error encountered during the HTTP request.
Exceptions
- ArgumentNullException
- Thrown if
client,requestorerroror isnull.
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.
cancellationTokenCancellationToken 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
schedulerFactoryisnull.
