Class HttpResponseException
- Namespace
- Kampute.HttpClient
- Assembly
- Kampute.HttpClient.dll
Represents an exception that is thrown when an HTTP request results in a failure HTTP status code.
public class HttpResponseException : HttpRequestException, ISerializable
- Inheritance
-
HttpResponseException
- Implements
- Inherited Members
- Extension Methods
Constructors
HttpResponseException(HttpStatusCode)
Initializes a new instance of the HttpResponseException class with the specified status code.
public HttpResponseException(HttpStatusCode statusCode)
Parameters
statusCode
HttpStatusCodeThe 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
statusCode
HttpStatusCodeThe HTTP status code associated with the exception.
message
stringThe 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
statusCode
HttpStatusCodeThe HTTP status code associated with the exception.
message
stringThe error message that explains the reason for the exception.
innerException
ExceptionThe exception that is the cause of the current exception, or a null reference 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 null if 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 null if 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
- object
The deserialized object from the HTTP response body. Can be null if the HTTP response is not deserialized.
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.