Class HttpException
Describes an HTTP error. These are commonly thrown by JsonClient as well as HTTP clients generated by neon-modelgen.
Namespace: Neon.Net
Assembly: Neon.Common.dll
Syntax
public class HttpException : Exception
Remarks
note
The ReasonPhrase property may be used as a way for services to return the computer readable specific error type. This is configured by default by Neon.Web builder extensions and REST services may specify these codes to our base controller Requires() methods or by throwning a HttpApiException.
Constructors
HttpException(HttpRequestException, string, string)
Constructs an exception from a HttpRequestException and optionals request details.
note
This constructor does not initialize the StatusCode property for
.NET Standard 2.x, .NET Core 3.x, and .NET Framework and the ReasonPhrase
is set to the message from requestException
.
Declaration
public HttpException(HttpRequestException requestException, string requestUri = null, string requestMethod = null)
Parameters
Type | Name | Description |
---|---|---|
HttpRequestException | requestException | The HttpRequestException. |
string | requestUri | Optionally specifies the request URL. |
string | requestMethod | Optionally specifies the request method. |
HttpException(HttpResponseMessage)
Constructs an exception from an HttpResponseMessage.
Declaration
public HttpException(HttpResponseMessage response)
Parameters
Type | Name | Description |
---|---|---|
HttpResponseMessage | response |
Exceptions
Type | Condition |
---|---|
InvalidOperationException | Thrown when the response message does not indicate an error. |
HttpException(string, string, string, HttpStatusCode)
Constructs an exception from the request and response details passed.
Declaration
public HttpException(string reasonPhrase = null, string requestUri = null, string requestMethod = null, HttpStatusCode statusCode = (HttpStatusCode)0)
Parameters
Type | Name | Description |
---|---|---|
string | reasonPhrase | The HTTP response reason phrase (or |
string | requestUri | Optionally specifies the request URL. |
string | requestMethod | Optionally specifies the request method. |
HttpStatusCode | statusCode | Optionally specifies the response status code. |
Properties
ReasonPhrase
Returns the HTTP response status message.
Declaration
public string ReasonPhrase { get; }
Property Value
Type | Description |
---|---|
string |
RequestMethod
Returns the request requestMethod when known.
Declaration
public string RequestMethod { get; }
Property Value
Type | Description |
---|---|
string |
RequestUri
Returns the request URI when known.
Declaration
public string RequestUri { get; }
Property Value
Type | Description |
---|---|
string |
StatusCode
Returns the HTTP response status code.
Declaration
public HttpStatusCode StatusCode { get; }
Property Value
Type | Description |
---|---|
HttpStatusCode |