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(Int32, String, Exception)
Initializes a new instance of the HttpStatusCodeException class.
protected HttpStatusCodeException(int statusCode, string message, Exception innerException = null)
Parameters
statusCode
Int32The HTTP status code to associate with this exception.
message
StringThe message that describes the HTTP status code.
innerException
ExceptionThe exception that is the cause of the current exception.
HttpStatusCodeException(Int32, String, String, Exception)
Initializes a new instance of the HttpStatusCodeException class.
protected HttpStatusCodeException(int statusCode, string reasonPhrase, string message, Exception innerException = null)
Parameters
statusCode
Int32The HTTP status code to associate with this exception.
reasonPhrase
StringThe HTTP reason phrase to associate with
statusCode
and this exception.message
StringThe message that describes the HTTP status code.
innerException
ExceptionThe 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
- Int32
The HTTP status code associated with this exception.
Methods
ToString()
Returns a String that represents this instance.
public override string ToString()
Returns
TryParse(Int32, out HttpStatusCodeException)
Attempts to resolve a suitable httpStatusCodeException
from the specified statusCode
.
public static bool TryParse(int statusCode, out HttpStatusCodeException httpStatusCodeException)
Parameters
statusCode
Int32The HTTP status code to associate with this exception.
httpStatusCodeException
HttpStatusCodeExceptionWhen this method returns, contains the by
statusCode
resolved HttpStatusCodeException, ornull
if no matches could be made.
Returns
- Boolean
true
if an instance of HttpStatusCodeException could be resolved,false
otherwise.
TryParse(Int32, 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
statusCode
Int32The HTTP status code to associate with this exception.
message
StringThe message that describes the HTTP status code.
httpStatusCodeException
HttpStatusCodeExceptionWhen this method returns, contains the by
statusCode
resolved HttpStatusCodeException, ornull
if no matches could be made.
Returns
- Boolean
true
if an instance of HttpStatusCodeException could be resolved,false
otherwise.
TryParse(Int32, 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
statusCode
Int32The HTTP status code to associate with this exception.
message
StringThe message that describes the HTTP status code.
innerException
ExceptionThe exception that is the cause of the current exception.
httpStatusCodeException
HttpStatusCodeExceptionWhen this method returns, contains the by
statusCode
resolved HttpStatusCodeException, ornull
if no matches could be made.
Returns
- Boolean
true
if an instance of HttpStatusCodeException could be resolved,false
otherwise.