pub struct ErrorContext {
pub details: Option<Value>,
pub suggestion: Option<Cow<'static, str>>,
}Expand description
Additional context for consolidated errors
Fields§
§details: Option<Value>Structured details for programmatic access
suggestion: Option<Cow<'static, str>>Human-readable suggestion for resolving the error
Implementations§
Source§impl ErrorContext
impl ErrorContext
Sourcepub const fn new(
details: Option<Value>,
suggestion: Option<Cow<'static, str>>,
) -> Self
pub const fn new( details: Option<Value>, suggestion: Option<Cow<'static, str>>, ) -> Self
Create a new error context with details and suggestion
Sourcepub const fn with_details(details: Value) -> Self
pub const fn with_details(details: Value) -> Self
Create error context with only details
Sourcepub const fn with_suggestion(suggestion: Cow<'static, str>) -> Self
pub const fn with_suggestion(suggestion: Cow<'static, str>) -> Self
Create error context with only suggestion
Sourcepub fn with_detail(key: &str, value: impl Serialize) -> Self
pub fn with_detail(key: &str, value: impl Serialize) -> Self
Builder method to add a single detail field
Sourcepub fn with_name_reason(name_field: &str, name: &str, reason: &str) -> Self
pub fn with_name_reason(name_field: &str, name: &str, reason: &str) -> Self
Builder method to add name and reason details
Sourcepub fn and_suggestion(self, suggestion: impl Into<String>) -> Self
pub fn and_suggestion(self, suggestion: impl Into<String>) -> Self
Add suggestion to existing context
Trait Implementations§
Source§impl Clone for ErrorContext
impl Clone for ErrorContext
Source§fn clone(&self) -> ErrorContext
fn clone(&self) -> ErrorContext
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 moreAuto 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