Table of Contents

Class XapiHttpException

Namespace
Xapi.Client
Assembly
Xapi.Client.dll

The LRS answered, but not with something the client can use: an error status, or a success status whose body does not follow the standard.

public class XapiHttpException : Exception, ISerializable
Inheritance
XapiHttpException
Implements
Derived
Inherited Members

Remarks

Failures below HTTP (DNS, refused connections, timeouts) are not wrapped: they surface as HttpRequestException and TaskCanceledException from HttpClient. The client does not retry; see IsTransient and RetryAfter for callers that do.

Constructors

XapiHttpException()

Creates an exception with a generic message and no status code.

public XapiHttpException()

XapiHttpException(string)

Creates an exception with a message and no status code.

public XapiHttpException(string message)

Parameters

message string

The message.

XapiHttpException(string, Exception)

Creates an exception with a message, an inner exception and no status code.

public XapiHttpException(string message, Exception innerException)

Parameters

message string

The message.

innerException Exception

The inner exception.

XapiHttpException(string, HttpStatusCode, string?, TimeSpan?, Exception?)

Creates an exception for an LRS response.

public XapiHttpException(string message, HttpStatusCode statusCode, string? responseBody = null, TimeSpan? retryAfter = null, Exception? innerException = null)

Parameters

message string

The message.

statusCode HttpStatusCode

The response status code.

responseBody string

The response body as text, if any.

retryAfter TimeSpan?

The delay the LRS asked for in a Retry-After header, if any.

innerException Exception

The inner exception, if any.

Properties

IsTransient

Whether the same request might succeed later: 408 Request Timeout, 429 Too Many Requests, and 5xx except 501 Not Implemented and 505 HTTP Version Not Supported.

public bool IsTransient { get; }

Property Value

bool

ResponseBody

The response body as text. LRSs usually explain the error here.

public string? ResponseBody { get; }

Property Value

string

RetryAfter

The delay the LRS asked for with Retry-After (usually with 429 or 503), already converted from an HTTP date to a delay where needed. null when the header was absent.

public TimeSpan? RetryAfter { get; }

Property Value

TimeSpan?

StatusCode

The HTTP status code of the response, or 0 when the exception was not created from a response.

public HttpStatusCode StatusCode { get; }

Property Value

HttpStatusCode