Class HttpStatusCodeException
- Namespace
- Cuemon.AspNetCore.Http
- Assembly
- Cuemon.AspNetCore.dll
Provides a base-class for exceptions based on an HTTP status code.
public abstract class HttpStatusCodeException : Exception, ISerializable
- Inheritance
-
HttpStatusCodeException
- Implements
- Derived
- Inherited Members
Constructors
HttpStatusCodeException(int, string, Exception)
Initializes a new instance of the HttpStatusCodeException class.
protected HttpStatusCodeException(int statusCode, string message, Exception innerException = null)
Parameters
statusCodeintThe HTTP status code to associate with this exception.
messagestringThe message that describes the HTTP status code.
innerExceptionExceptionThe exception that is the cause of the current exception.
HttpStatusCodeException(int, string, string, Exception)
Initializes a new instance of the HttpStatusCodeException class.
protected HttpStatusCodeException(int statusCode, string reasonPhrase, string message, Exception innerException = null)
Parameters
statusCodeintThe HTTP status code to associate with this exception.
reasonPhrasestringThe HTTP reason phrase to associate with
statusCodeand this exception.messagestringThe message that describes the HTTP status code.
innerExceptionExceptionThe exception that is the cause of the current exception.
Properties
Headers
Gets the collection of HTTP response headers.
public IHeaderDictionary Headers { get; }
Property Value
- IHeaderDictionary
The collection of HTTP response headers.
ReasonPhrase
Gets the HTTP reason phrase associated with this exception.
public string ReasonPhrase { get; }
Property Value
- string
The HTTP reason phrase associated with this exception.
StatusCode
Gets the HTTP status code associated with this exception.
public int StatusCode { get; }
Property Value
- int
The HTTP status code associated with this exception.
Methods
ToString()
Returns a string that represents this instance.
public override string ToString()
Returns
TryParse(int, out HttpStatusCodeException)
Attempts to resolve a suitable httpStatusCodeException from the specified statusCode.
public static bool TryParse(int statusCode, out HttpStatusCodeException httpStatusCodeException)
Parameters
statusCodeintThe HTTP status code to associate with this exception.
httpStatusCodeExceptionHttpStatusCodeExceptionWhen this method returns, contains the by
statusCoderesolved HttpStatusCodeException, ornullif no matches could be made.
Returns
- bool
trueif an instance of HttpStatusCodeException could be resolved,falseotherwise.
TryParse(int, string, out HttpStatusCodeException)
Attempts to resolve a suitable httpStatusCodeException from the specified statusCode.
public static bool TryParse(int statusCode, string message, out HttpStatusCodeException httpStatusCodeException)
Parameters
statusCodeintThe HTTP status code to associate with this exception.
messagestringThe message that describes the HTTP status code.
httpStatusCodeExceptionHttpStatusCodeExceptionWhen this method returns, contains the by
statusCoderesolved HttpStatusCodeException, ornullif no matches could be made.
Returns
- bool
trueif an instance of HttpStatusCodeException could be resolved,falseotherwise.
TryParse(int, string, Exception, out HttpStatusCodeException)
Attempts to resolve a suitable httpStatusCodeException from the specified statusCode.
public static bool TryParse(int statusCode, string message, Exception innerException, out HttpStatusCodeException httpStatusCodeException)
Parameters
statusCodeintThe HTTP status code to associate with this exception.
messagestringThe message that describes the HTTP status code.
innerExceptionExceptionThe exception that is the cause of the current exception.
httpStatusCodeExceptionHttpStatusCodeExceptionWhen this method returns, contains the by
statusCoderesolved HttpStatusCodeException, ornullif no matches could be made.
Returns
- bool
trueif an instance of HttpStatusCodeException could be resolved,falseotherwise.