Class HttpApiException
Thrown by ASP.NET web API implementations to optionally specify an error code that can ultimately be deserialized as the HTTP reason phrase by clients.
Namespace: Neon.Net
Assembly: Neon.Common.dll
Syntax
public class HttpApiException : Exception
Remarks
The basic idea here is that non-type REST services will typically need to return a computer readable code to specify business logic level errors so that client programs can easily identify and handle problems without the need for parsing a potentially localized error message.
note
We're restricting error codes to 1-32 characters including ASCII letters, digits, undercores, dots, or dashes.
note
This error code will be transmitted back to the client as the >HTTP reason phrase when specified or the standard reason phrase associated with the HTTP status code otherwise.
Constructors
HttpApiException(string, string, HttpStatusCode)
Constructor.
Declaration
public HttpApiException(string message = null, string errorCode = null, HttpStatusCode statusCode = HttpStatusCode.BadRequest)
Parameters
Type | Name | Description |
---|---|---|
string | message | Optionally specifies the exception message. |
string | errorCode | Optionally specifies the HttpStatusCode. This |
HttpStatusCode | statusCode | Optionally specifies the HTTP status code. This defaults to BadRequest. |
Remarks
note
errorCode
is restricted to 1-32 characters including ASCII letters, digits,
undercores, dots, or dashes.
Properties
ErrorCode
Returns the business logic error code or null
.
Declaration
public string ErrorCode { get; }
Property Value
Type | Description |
---|---|
string |
StatusCode
Returns the HTTP status code.
Declaration
public HttpStatusCode StatusCode { get; }
Property Value
Type | Description |
---|---|
HttpStatusCode |