pub struct LocalizedError {
pub code: ErrorCode,
pub reason: String,
pub details: Option<String>,
pub params: Option<HashMap<String, String>>,
pub timestamp: DateTime<Utc>,
}Expand description
国际化错误信息结构
Fields§
§code: ErrorCode错误代码
reason: String错误原因(用于国际化)
details: Option<String>错误详情(可选,用于调试)
params: Option<HashMap<String, String>>错误参数(用于国际化插值)
timestamp: DateTime<Utc>错误时间戳
Implementations§
Source§impl LocalizedError
impl LocalizedError
Sourcepub fn with_details(self, details: impl Into<String>) -> Self
pub fn with_details(self, details: impl Into<String>) -> Self
添加错误详情
Sourcepub fn with_params(self, params: HashMap<String, String>) -> Self
pub fn with_params(self, params: HashMap<String, String>) -> Self
添加错误参数
Sourcepub fn code_value(&self) -> u32
pub fn code_value(&self) -> u32
获取错误代码的数字值
Sourcepub fn category(&self) -> ErrorCategory
pub fn category(&self) -> ErrorCategory
获取错误类别
Sourcepub fn is_retryable(&self) -> bool
pub fn is_retryable(&self) -> bool
判断是否为可重试的错误
Trait Implementations§
Source§impl Clone for LocalizedError
impl Clone for LocalizedError
Source§fn clone(&self) -> LocalizedError
fn clone(&self) -> LocalizedError
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · 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 LocalizedError
impl Debug for LocalizedError
Source§impl<'de> Deserialize<'de> for LocalizedError
impl<'de> Deserialize<'de> for LocalizedError
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 Display for LocalizedError
impl Display for LocalizedError
Auto Trait Implementations§
impl Freeze for LocalizedError
impl RefUnwindSafe for LocalizedError
impl Send for LocalizedError
impl Sync for LocalizedError
impl Unpin for LocalizedError
impl UnsafeUnpin for LocalizedError
impl UnwindSafe for LocalizedError
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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