Class XapiHttpException
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
messagestringThe message.
XapiHttpException(string, Exception)
Creates an exception with a message, an inner exception and no status code.
public XapiHttpException(string message, Exception innerException)
Parameters
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
messagestringThe message.
statusCodeHttpStatusCodeThe response status code.
responseBodystringThe response body as text, if any.
retryAfterTimeSpan?The delay the LRS asked for in a
Retry-Afterheader, if any.innerExceptionExceptionThe 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
ResponseBody
The response body as text. LRSs usually explain the error here.
public string? ResponseBody { get; }
Property Value
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
StatusCode
The HTTP status code of the response, or 0 when the exception was not created from a response.
public HttpStatusCode StatusCode { get; }