pub enum ErrorCategory {
Show 13 variants
Validation,
Auth,
Permission,
NotFound,
Conflict,
RateLimited,
Network,
Storage,
Database,
Cache,
Config,
Timeout,
Internal,
}Expand description
错误分类
用于将错误映射到 HTTP 状态码等场景。
Variants§
Validation
验证错误 (400)
Auth
认证错误 (401)
Permission
权限错误 (403)
NotFound
资源未找到 (404)
Conflict
请求冲突 (409)
RateLimited
请求过多 (429)
Network
网络/服务错误 (502/503)
Storage
存储错误 (500)
Database
数据库错误 (500)
Cache
缓存错误 (500)
Config
配置错误 (500)
Timeout
超时错误 (408/504)
Internal
内部错误 (500)
Implementations§
Source§impl ErrorCategory
impl ErrorCategory
Sourcepub fn http_status(&self) -> u16
pub fn http_status(&self) -> u16
获取对应的 HTTP 状态码
Trait Implementations§
Source§impl Clone for ErrorCategory
impl Clone for ErrorCategory
Source§fn clone(&self) -> ErrorCategory
fn clone(&self) -> ErrorCategory
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ErrorCategory
impl Debug for ErrorCategory
Source§impl<'de> Deserialize<'de> for ErrorCategory
impl<'de> Deserialize<'de> for ErrorCategory
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialEq for ErrorCategory
impl PartialEq for ErrorCategory
Source§impl Serialize for ErrorCategory
impl Serialize for ErrorCategory
impl Copy for ErrorCategory
impl Eq for ErrorCategory
impl StructuralPartialEq for ErrorCategory
Auto Trait Implementations§
impl Freeze for ErrorCategory
impl RefUnwindSafe for ErrorCategory
impl Send for ErrorCategory
impl Sync for ErrorCategory
impl Unpin for ErrorCategory
impl UnsafeUnpin for ErrorCategory
impl UnwindSafe for ErrorCategory
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