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
HttpRestClientThe HttpRestClient instance used to send the request.
request
HttpRequestMessageThe HttpRequestMessage that resulted in a failure.
response
HttpResponseMessageThe HttpResponseMessage indicating the failure.
error
HttpResponseExceptionThe Exception containing details of the error encountered during the HTTP request.
Exceptions
- ArgumentNullException
Thrown if
client
,request
,response
orerror
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
CancellationTokenA 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.