pub enum ServerError {
IoError(Error),
ParseError(String),
ValidationError(String),
NotFound,
BadRequest(String),
Unauthorized(String),
Forbidden(String),
InternalError(String),
Conflict(String),
PanicError(String),
TooManyRequests,
}Variants§
IoError(Error)
ParseError(String)
ValidationError(String)
NotFound
BadRequest(String)
Forbidden(String)
InternalError(String)
Conflict(String)
PanicError(String)
TooManyRequests
Implementations§
Source§impl ServerError
impl ServerError
Sourcepub fn status_code(&self) -> u16
pub fn status_code(&self) -> u16
Examples found in repository?
examples/middleware.rs (line 24)
16 fn call(&self, req: Request, next: Next) -> MiddlewareResult {
17 Box::pin(async move {
18 let start = Instant::now();
19 let url = req.path.clone();
20 let method = req.method.clone();
21 let res = next.handle(req).await;
22 let status = match &res {
23 Ok(res) => res.status,
24 Err(err) => err.status_code(),
25 };
26 let duration = start.elapsed().as_millis();
27 println!("[{}] {:?} {} - {}ms", status, method, url, duration);
28 res
29 })
30 }Trait Implementations§
Source§impl Debug for ServerError
impl Debug for ServerError
Source§impl Display for ServerError
impl Display for ServerError
Source§impl Error for ServerError
impl Error for ServerError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0: use the Display impl or to_string()
Auto Trait Implementations§
impl Freeze for ServerError
impl !RefUnwindSafe for ServerError
impl Send for ServerError
impl Sync for ServerError
impl Unpin for ServerError
impl !UnwindSafe for ServerError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more