[−][src]Enum sharp_pencil::http_errors::HTTPError
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
Implementations
impl HTTPError
[src]
pub fn new(code: u16) -> HTTPError
[src]
Create a new HTTPError
.
pub fn code(&self) -> u16
[src]
The status code.
pub fn name(&self) -> &str
[src]
The status name.
pub fn get_body(&self) -> String
[src]
Get the HTML body.
pub fn to_response(&self) -> Response
[src]
Get a response object.
Trait Implementations
impl Clone for HTTPError
[src]
impl Debug for HTTPError
[src]
impl Display for HTTPError
[src]
impl Error for HTTPError
[src]
fn description(&self) -> &str
[src]
fn source(&self) -> Option<&(dyn Error + 'static)>
1.30.0[src]
fn backtrace(&self) -> Option<&Backtrace>
[src]
fn cause(&self) -> Option<&dyn Error>
1.0.0[src]
impl From<HTTPError> for PencilError
[src]
fn from(err: HTTPError) -> PencilError
[src]
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
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> CloneAny for T where
T: Clone + Any,
[src]
T: Clone + Any,
fn clone_any(&self) -> Box<dyn CloneAny + 'static>
[src]
fn clone_any_send(&self) -> Box<dyn CloneAny + 'static + Send> where
T: Send,
[src]
T: Send,
fn clone_any_sync(&self) -> Box<dyn CloneAny + 'static + Sync> where
T: Sync,
[src]
T: Sync,
fn clone_any_send_sync(&self) -> Box<dyn CloneAny + 'static + Sync + Send> where
T: Send + Sync,
[src]
T: Send + Sync,
impl<T> DebugAny for T where
T: Any + Debug,
[src]
T: Any + Debug,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Typeable for T where
T: Any,
T: Any,
impl<T> UnsafeAny for T where
T: Any,
T: Any,