pub struct ErrorDetail {
pub code: i32,
pub message: String,
pub details: Option<HashMap<String, Value>>,
}Expand description
错误详情结构 / Error detail structure
Fields§
§code: i32错误码 / Error code
message: String人类可读的错误描述 / Human readable error message
details: Option<HashMap<String, Value>>结构化调试信息(可选)/ Structured debug info (optional)
Implementations§
Source§impl ErrorDetail
impl ErrorDetail
Sourcepub fn new(code: i32, message: impl Into<String>) -> ErrorDetail
pub fn new(code: i32, message: impl Into<String>) -> ErrorDetail
创建新的错误详情 / Create new error detail
Sourcepub fn with_detail(
self,
key: impl Into<String>,
value: impl Into<Value>,
) -> ErrorDetail
pub fn with_detail( self, key: impl Into<String>, value: impl Into<Value>, ) -> ErrorDetail
添加详情字段 / Add detail field
Sourcepub fn with_details(self, details: HashMap<String, Value>) -> ErrorDetail
pub fn with_details(self, details: HashMap<String, Value>) -> ErrorDetail
添加多个详情字段 / Add multiple detail fields
Trait Implementations§
Source§impl Clone for ErrorDetail
impl Clone for ErrorDetail
Source§fn clone(&self) -> ErrorDetail
fn clone(&self) -> ErrorDetail
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 ErrorDetail
impl Debug for ErrorDetail
Source§impl<'de> Deserialize<'de> for ErrorDetail
impl<'de> Deserialize<'de> for ErrorDetail
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<ErrorDetail, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<ErrorDetail, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Serialize for ErrorDetail
impl Serialize for ErrorDetail
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
Auto Trait Implementations§
impl Freeze for ErrorDetail
impl RefUnwindSafe for ErrorDetail
impl Send for ErrorDetail
impl Sync for ErrorDetail
impl Unpin for ErrorDetail
impl UnsafeUnpin for ErrorDetail
impl UnwindSafe for ErrorDetail
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