Enum sharp_pencil::http_errors::HTTPError
source · [−]pub enum HTTPError {
Show 25 variants
BadRequest,
Unauthorized,
Forbidden,
NotFound,
MethodNotAllowed(Option<Vec<Method>>),
NotAcceptable,
RequestTimeout,
Conflict,
Gone,
LengthRequired,
PreconditionFailed,
RequestEntityTooLarge,
RequestURITooLarge,
UnsupportedMediaType,
RequestedRangeNotSatisfiable,
ExpectationFailed,
ImATeapot,
UnprocessableEntity,
PreconditionRequired,
TooManyRequests,
RequestHeaderFieldsTooLarge,
InternalServerError,
NotImplemented,
BadGateway,
ServiceUnavailable,
}
Expand description
The HTTP Error type you can return from within your views to trigger a non-200 response. Here is one usage example:
use sharp_pencil::{Request, PencilResult, PenHTTPError};
use sharp_pencil::http_errors::NotFound;
fn view(_: &mut Request) -> PencilResult {
return Err(PenHTTPError(NotFound))
}
Pencil comes with a shortcut that can be used to return non-200 HTTP error easily:
use sharp_pencil::{Request, PencilResult};
use sharp_pencil::abort;
fn view(_: &mut Request) -> PencilResult {
return abort(404)
}
Variants
BadRequest
Unauthorized
Forbidden
NotFound
MethodNotAllowed(Option<Vec<Method>>)
NotAcceptable
RequestTimeout
Conflict
Gone
LengthRequired
PreconditionFailed
RequestEntityTooLarge
RequestURITooLarge
UnsupportedMediaType
RequestedRangeNotSatisfiable
ExpectationFailed
ImATeapot
UnprocessableEntity
PreconditionRequired
TooManyRequests
RequestHeaderFieldsTooLarge
InternalServerError
NotImplemented
BadGateway
ServiceUnavailable
Implementations
Trait Implementations
sourceimpl Error for HTTPError
impl Error for HTTPError
sourcefn description(&self) -> &str
fn description(&self) -> &str
👎 Deprecated since 1.42.0:
use the Display impl or to_string()
1.30.0 · sourcefn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
The lower-level source of this error, if any. Read more
sourcefn backtrace(&self) -> Option<&Backtrace>
fn backtrace(&self) -> Option<&Backtrace>
🔬 This is a nightly-only experimental API. (
backtrace
)Returns a stack backtrace, if available, of where this error occurred. Read more
sourceimpl From<HTTPError> for PencilError
impl From<HTTPError> for PencilError
sourcefn from(err: HTTPError) -> PencilError
fn from(err: HTTPError) -> PencilError
Converts to this type from the input type.
Auto Trait Implementations
impl RefUnwindSafe for HTTPError
impl Send for HTTPError
impl Sync for HTTPError
impl Unpin for HTTPError
impl UnwindSafe for HTTPError
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more