pub enum Error {
Show 22 variants
BadRequest,
Exists(Cow<'static, str>),
SerdeJson(Error),
Str(Cow<'static, str>),
String(String),
Regex(Error),
Unauthorized(&'static str),
Forbidden,
NotFound(Cow<'static, str>),
Option(Cow<'static, str>),
Unsupport(Cow<'static, str>),
UnprocessableEntity {
errors: HashMap<Cow<'static, str>, Vec<Cow<'static, str>>>,
},
TryFromSlice(TryFromSliceError),
Io(Error),
Env(VarError),
Empty,
Std(Box<dyn Error + Send + Sync>),
ParseNumber(ParseIntError),
ParseFloatError(ParseFloatError),
Log(Cow<'static, str>),
Nul(NulError),
Any {
err: Box<dyn Any + Send + Sync>,
},
}Expand description
Http share error
Variants§
BadRequest
BadRequest 400 Bad Request
Exists(Cow<'static, str>)
已存在
SerdeJson(Error)
SerdeJson 400 Bad Request
Str(Cow<'static, str>)
Result 400 Bad Request
String(String)
Regex(Error)
Excel 400 Bad Request
Return 401 Unauthorized
Forbidden
Return 403 Forbidden
NotFound(Cow<'static, str>)
Return 404 Not Found
Option(Cow<'static, str>)
Return 404 Not Found
Unsupport(Cow<'static, str>)
不支持
UnprocessableEntity
Return 422 Unprocessable Entity
TryFromSlice(TryFromSliceError)
Io(Error)
IO return 500 INTERNAL_SERVER_ERROR
Env(VarError)
Env
Empty
Std(Box<dyn Error + Send + Sync>)
Std error return 500 INTERNAL_SERVER_ERROR
ParseNumber(ParseIntError)
Parse int error return 400
ParseFloatError(ParseFloatError)
Parse float error return 400
Log(Cow<'static, str>)
Return 502 Internal Server Error on an anyhow::Error.
Nul(NulError)
Nul
Any
Any
Implementations§
source§impl Error
impl Error
sourcepub fn unprocessable_entity<K, V>(
errors: impl IntoIterator<Item = (K, V)>
) -> Self
pub fn unprocessable_entity<K, V>( errors: impl IntoIterator<Item = (K, V)> ) -> Self
Convenient constructor for Self::UnprocessableEntity.
sourcepub fn status_code(&self) -> StatusCode
pub fn status_code(&self) -> StatusCode
状态码获取
Trait Implementations§
source§impl Error for Error
impl Error for Error
source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
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()
source§impl From<ParseFloatError> for Error
impl From<ParseFloatError> for Error
source§fn from(source: ParseFloatError) -> Self
fn from(source: ParseFloatError) -> Self
Converts to this type from the input type.
source§impl From<ParseIntError> for Error
impl From<ParseIntError> for Error
source§fn from(source: ParseIntError) -> Self
fn from(source: ParseIntError) -> Self
Converts to this type from the input type.
source§impl From<TryFromSliceError> for Error
impl From<TryFromSliceError> for Error
source§fn from(source: TryFromSliceError) -> Self
fn from(source: TryFromSliceError) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl Freeze for Error
impl !RefUnwindSafe for Error
impl Send for Error
impl Sync for Error
impl Unpin for Error
impl !UnwindSafe for Error
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
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more