HttpResponseException Class
- Namespace
- Kampute.HttpClient
- Assembly
- Kampute.HttpClient.dll
Definition
Represents an exception that is thrown when an HTTP request results in a failure HTTP status code.
public class HttpResponseException : HttpRequestException- Inheritance
- object
- Exception
- HttpRequestException
- HttpResponseException
Constructors
HttpResponseException(HttpStatusCode)
Initializes a new instance of the HttpResponseException class with the specified status code.
public HttpResponseException(HttpStatusCode statusCode)Parameters
statusCodeHttpStatusCode- The HTTP status code associated with the exception.
HttpResponseException(HttpStatusCode, string)
Initializes a new instance of the HttpResponseException class with the specified status code and error message.
public HttpResponseException(HttpStatusCode statusCode, string message)Parameters
statusCodeHttpStatusCode- The HTTP status code associated with the exception.
messagestring- The error message that explains the reason for the exception.
HttpResponseException(HttpStatusCode, string, Exception)
Initializes a new instance of the HttpResponseException class with the specified status code, error message, and optional inner exception.
public HttpResponseException(HttpStatusCode statusCode, string message, Exception innerException)Parameters
statusCodeHttpStatusCode- The HTTP status code associated with the exception.
messagestring- The error message that explains the reason for the exception.
innerExceptionException- The exception that is the cause of the current exception, or a
nullreference if no inner exception is specified.
Properties
Errors
Gets or sets the validation errors associated with the exception.
public IDictionary<string, string[]> Errors { get; set; }Property Value
- IDictionary<string, string[]>
- The validation errors associated with the exception, if any. It maps error keys to their corresponding error messages arrays. Can be
nullif there are no validation errors.
ResponseMessage
Gets or sets the HTTP response message associated with the exception.
public HttpResponseMessage ResponseMessage { get; set; }Property Value
- HttpResponseMessage
- The HTTP response message associated with the exception. Can be
nullif there is no HTTP response message.
ResponseObject
Gets or sets the deserialized object from the HTTP response associated with the exception.
public object ResponseObject { get; set; }Property Value
StatusCode
Gets the HTTP status code associated with the exception.
public HttpStatusCode StatusCode { get; }Property Value
- HttpStatusCode
- The HTTP status code associated with the exception.
Methods
ToString()
Creates and returns a string representation of the current exception.
public override string ToString()Returns
- string
- A string representation of the current exception.
Extension Methods
| IsTransientNetworkError(this Exception) | Determines whether a given exception can be considered as a transient network issue for the purposes of retrying an HTTP request. |
