HttpResponseErrorContext Class
- Namespace
- Kampute.HttpClient
- Assembly
- Kampute.HttpClient.dll
Definition
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
- object
- HttpRequestErrorContext
- HttpResponseErrorContext
Constructors
HttpResponseErrorContext(HttpRestClient, HttpRequestMessage, HttpResponseMessage, HttpResponseException)
Initializes an instance of the HttpResponseErrorContext class.
public HttpResponseErrorContext(
HttpRestClient client,
HttpRequestMessage request,
HttpResponseMessage response,
HttpResponseException error)Parameters
clientHttpRestClient- The HttpRestClient instance used to send the request.
requestHttpRequestMessage- The HttpRequestMessage that resulted in a failure.
responseHttpResponseMessage- The HttpResponseMessage indicating the failure.
errorHttpResponseException- The Exception containing details of the error encountered during the HTTP request.
Exceptions
- ArgumentNullException
- Thrown if
client,request,responseorerroror isnull.
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
schedulerFactoryFunc<HttpResponseErrorContext, 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.
