pub struct ErrorContext { /* private fields */ }Expand description
Builder-style context wrapper used by public crate error types.
Implementations§
Source§impl ErrorContext
impl ErrorContext
Sourcepub fn new(
code: ErrorCode,
message: impl Into<String>,
remediation: Remediation,
) -> Self
pub fn new( code: ErrorCode, message: impl Into<String>, remediation: Remediation, ) -> Self
Creates a new error context with the required code, message, and remediation.
Sourcepub fn cause(self, cause: impl Into<String>) -> Self
pub fn cause(self, cause: impl Into<String>) -> Self
Adds a human-readable cause string to the error context.
Sourcepub fn docs(self, docs: impl Into<String>) -> Self
pub fn docs(self, docs: impl Into<String>) -> Self
Adds a documentation reference string to the error context.
Sourcepub fn detail(self, key: impl Into<String>, value: Value) -> Self
pub fn detail(self, key: impl Into<String>, value: Value) -> Self
Adds one structured detail field to the error context.
Sourcepub fn source(self, source: Box<dyn Error + Send + Sync + 'static>) -> Self
pub fn source(self, source: Box<dyn Error + Send + Sync + 'static>) -> Self
Captures the real source error for display and error chaining.
Sourcepub fn diagnostic(&self) -> &Diagnostic
pub fn diagnostic(&self) -> &Diagnostic
Returns the structured diagnostic carried by this error context.
Trait Implementations§
Source§impl Debug for ErrorContext
impl Debug for ErrorContext
Source§impl<'de> Deserialize<'de> for ErrorContext
impl<'de> Deserialize<'de> for ErrorContext
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 ErrorContext
impl Display for ErrorContext
Source§impl Error for ErrorContext
impl Error for ErrorContext
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 PartialEq for ErrorContext
impl PartialEq for ErrorContext
Auto Trait Implementations§
impl !Freeze for ErrorContext
impl !RefUnwindSafe for ErrorContext
impl Send for ErrorContext
impl Sync for ErrorContext
impl Unpin for ErrorContext
impl UnsafeUnpin for ErrorContext
impl !UnwindSafe for ErrorContext
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