pub struct CodedError {
pub code: ErrorCode,
pub message: String,
pub source: Option<Error>,
}Expand description
带错误码的通用错误载体。
所有可以通过 crate 边界传播的错误都应包装为 CodedError,
确保接收方可以拿到稳定的错误码而不是解析字符串。
Fields§
§code: ErrorCode§message: String§source: Option<Error>可选的底层错误(用于日志 / 调试,不进入用户可见消息)。
Implementations§
Trait Implementations§
Source§impl Debug for CodedError
impl Debug for CodedError
Source§impl Display for CodedError
impl Display for CodedError
Source§impl Error for CodedError
impl Error for CodedError
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()
Auto Trait Implementations§
impl Forget for CodedError
impl Freeze for CodedError
impl Move for CodedError
impl RefUnwindSafe for CodedErrorwhere
Error: RefUnwindSafe,
impl Send for CodedError
impl Sync for CodedError
impl Unpin for CodedError
impl UnsafeUnpin for CodedErrorwhere
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
*const ErrorImpl is !null: UnsafeUnpin,
impl UnwindSafe for CodedError
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