HttpResponseErrorContext Class
- Namespace
- Kampute.HttpClient
- Assembly
- Kampute.HttpClient.dll
Definition
Describes an error response to the error handlers that decide whether to retry the request: the client, the request, the response, and the error.
public class HttpResponseErrorContext : HttpRequestErrorContext- Inheritance
- object
- HttpRequestErrorContext
- HttpResponseErrorContext
Constructors
HttpResponseErrorContext(HttpRestClient, HttpRequestMessage, HttpResponseMessage, HttpResponseException, HttpRetryState)
Initializes a new instance of the HttpResponseErrorContext class.
public HttpResponseErrorContext(
HttpRestClient client,
HttpRequestMessage request,
HttpResponseMessage response,
HttpResponseException error,
HttpRetryState retryState)Parameters
clientHttpRestClient- The client that sent the request.
requestHttpRequestMessage- The request that received the error response.
responseHttpResponseMessage- The error response.
errorHttpResponseException- The exception for the error response.
retryStateHttpRetryState- The retry state of the call that sent the request, shared by all its attempts.
Exceptions
- ArgumentNullException
- Thrown if
client,request,response,errororretryStateisnull.
Properties
Error
Gets the exception for the error response.
public HttpResponseException Error { get; }Property Value
- HttpResponseException
- The HttpResponseException that the client throws if no handler retries the request.
Response
Gets the error response.
public HttpResponseMessage Response { get; }Property Value
- HttpResponseMessage
- The HttpResponseMessage with the error status code.
Methods
ScheduleRetryAsync(object, Func<HttpResponseErrorContext, IRetrySession>, CancellationToken)
Waits as the retry session of the source decides, and returns a clone of the request to retry, or a decision not to retry.
public Task<HttpErrorHandlerResult> ScheduleRetryAsync(object source, Func<HttpResponseErrorContext, IRetrySession> sessionFactory, CancellationToken cancellationToken = default)Parameters
sourceobject- The component that handles this kind of failure and counts its retries, typically the IHttpErrorHandler that handles the response.
sessionFactoryFunc<HttpResponseErrorContext, IRetrySession>- A function that creates the retry session of the source from this context, or returns
nullif the source does not retry. cancellationTokenCancellationToken optional- A token that can be used to cancel the operation.
Returns
- Task<HttpErrorHandlerResult>
- A task that resolves, after the wait, to a decision to retry with a clone of the request, or to HttpErrorHandlerResult.NoRetry.
Exceptions
- ArgumentNullException
- Thrown if
sourceorsessionFactoryisnull.
Remarks
Each source has its own retry session for a call, as described for HttpRequestErrorContext.ScheduleRetryAsync(object, Func<HttpRequestErrorContext, IRetrySession>, CancellationToken).
