using System; using System.Net; namespace EmbedIO { partial class HttpException { /// /// Returns a new instance of that, when thrown, /// will break the request handling control flow and send a 500 Internal Server Error /// response to the client. /// /// A message to include in the response. /// The data object to include in the response. /// /// A newly-created . /// public static HttpException InternalServerError(string? message = null, object? data = null) => new HttpException(HttpStatusCode.InternalServerError, message, data); /// /// Returns a new instance of that, when thrown, /// will break the request handling control flow and send a 401 Unauthorized /// response to the client. /// /// A message to include in the response. /// The data object to include in the response. /// /// A newly-created . /// public static HttpException Unauthorized(string? message = null, object? data = null) => new HttpException(HttpStatusCode.Unauthorized, message, data); /// /// Returns a new instance of that, when thrown, /// will break the request handling control flow and send a 403 Forbidden /// response to the client. /// /// A message to include in the response. /// The data object to include in the response. /// A newly-created . public static HttpException Forbidden(string? message = null, object? data = null) => new HttpException(HttpStatusCode.Forbidden, message, data); /// /// Returns a new instance of that, when thrown, /// will break the request handling control flow and send a 400 Bad Request /// response to the client. /// /// A message to include in the response. /// The data object to include in the response. /// A newly-created . public static HttpException BadRequest(string? message = null, object? data = null) => new HttpException(HttpStatusCode.BadRequest, message, data); /// /// Returns a new instance of that, when thrown, /// will break the request handling control flow and send a 404 Not Found /// response to the client. /// /// A message to include in the response. /// The data object to include in the response. /// A newly-created . public static HttpException NotFound(string? message = null, object? data = null) => new HttpException(HttpStatusCode.NotFound, message, data); /// /// Returns a new instance of that, when thrown, /// will break the request handling control flow and send a 405 Method Not Allowed /// response to the client. /// /// A message to include in the response. /// The data object to include in the response. /// A newly-created . public static HttpException MethodNotAllowed(string? message = null, object? data = null) => new HttpException(HttpStatusCode.MethodNotAllowed, message, data); /// /// Returns a new instance of that, when thrown, /// will break the request handling control flow and send a 406 Not Acceptable /// response to the client. /// /// A newly-created . /// public static HttpNotAcceptableException NotAcceptable() => new HttpNotAcceptableException(); /// /// Returns a new instance of that, when thrown, /// will break the request handling control flow and send a 406 Not Acceptable /// response to the client. /// /// A value, or a comma-separated list of values, to set the response's Vary header to. /// A newly-created . /// public static HttpNotAcceptableException NotAcceptable(string vary) => new HttpNotAcceptableException(vary); /// /// Returns a new instance of that, when thrown, /// will break the request handling control flow and send a 416 Range Not Satisfiable /// response to the client. /// /// A newly-created . /// public static HttpRangeNotSatisfiableException RangeNotSatisfiable() => new HttpRangeNotSatisfiableException(); /// /// Returns a new instance of that, when thrown, /// will break the request handling control flow and send a 416 Range Not Satisfiable /// response to the client. /// /// The total length of the requested resource, expressed in bytes, /// or to omit the Content-Range header in the response. /// A newly-created . /// public static HttpRangeNotSatisfiableException RangeNotSatisfiable(long? contentLength) => new HttpRangeNotSatisfiableException(contentLength); /// /// Returns a new instance of that, when thrown, /// will break the request handling control flow and redirect the client /// to the specified location, using response status code 302. /// /// The redirection target. /// /// A newly-created . /// public static HttpRedirectException Redirect(string location) => new HttpRedirectException(location); /// /// Returns a new instance of that, when thrown, /// will break the request handling control flow and redirect the client /// to the specified location, using the specified response status code. /// /// The redirection target. /// The status code to set on the response, in the range from 300 to 399. /// /// A newly-created . /// /// is not in the 300-399 range. public static HttpRedirectException Redirect(string location, int statusCode) => new HttpRedirectException(location, statusCode); /// /// Returns a new instance of that, when thrown, /// will break the request handling control flow and redirect the client /// to the specified location, using the specified response status code. /// /// The redirection target. /// One of the redirection status codes, to be set on the response. /// /// A newly-created . /// /// is not a redirection status code. public static HttpRedirectException Redirect(string location, HttpStatusCode statusCode) => new HttpRedirectException(location, statusCode); } }