pub struct Error {
pub code: String,
pub message: String,
pub data: Option<Value>,
}Expand description
结构化错误,序列化为 { code, message, data? } 返回给前端。
Fields§
§code: String机器可读的错误码,通常取自 codes,也可能是 Python 自定义的错误码。
message: String面向开发者的错误描述。
data: Option<Value>可选的附加数据(任意 JSON),为 None 时序列化结果中不包含该字段。
Implementations§
Trait Implementations§
Source§impl Error for Error
impl Error for Error
1.30.0 · 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()
Source§impl From<ProtocolError> for Error
impl From<ProtocolError> for Error
Source§fn from(e: ProtocolError) -> Self
fn from(e: ProtocolError) -> Self
Converts to this type from the input type.
impl StructuralPartialEq for Error
Auto Trait Implementations§
impl Forget for Error
impl Freeze for Error
impl Move for Error
impl RefUnwindSafe for Error
impl Send for Error
impl Sync for Error
impl Unpin for Error
impl UnsafeUnpin 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