pub struct ErrorContext {
pub operation: String,
pub device: Option<String>,
pub backend: Option<String>,
pub details: Option<String>,
pub severity: ErrorSeverity,
pub category: ErrorCategory,
pub timestamp: SystemTime,
pub source_location: Option<String>,
pub thread_id: Option<String>,
pub cause: Option<Box<ErrorContext>>,
pub recovery_suggestions: Vec<String>,
pub error_code: Option<String>,
}Expand description
Enhanced error context information for better debugging
Fields§
§operation: StringThe operation being performed when error occurred
device: Option<String>Device where the error occurred
backend: Option<String>Backend type where the error occurred
details: Option<String>Additional context information
severity: ErrorSeverityError severity level
category: ErrorCategoryError category
timestamp: SystemTimeTimestamp when error occurred
source_location: Option<String>Source location (file:line) where error originated
thread_id: Option<String>Thread ID where error occurred
cause: Option<Box<ErrorContext>>Error chain - previous error that led to this one
recovery_suggestions: Vec<String>Suggested recovery actions
error_code: Option<String>Error code for programmatic handling
Implementations§
Source§impl ErrorContext
impl ErrorContext
Sourcepub fn new_with_category(
operation: impl Into<String>,
category: ErrorCategory,
severity: ErrorSeverity,
) -> Self
pub fn new_with_category( operation: impl Into<String>, category: ErrorCategory, severity: ErrorSeverity, ) -> Self
Create a new error context with category and severity
Sourcepub fn with_device(self, device: impl Into<String>) -> Self
pub fn with_device(self, device: impl Into<String>) -> Self
Add device information
Sourcepub fn with_backend(self, backend: impl Into<String>) -> Self
pub fn with_backend(self, backend: impl Into<String>) -> Self
Add backend information
Sourcepub fn with_details(self, details: impl Into<String>) -> Self
pub fn with_details(self, details: impl Into<String>) -> Self
Add additional details
Sourcepub fn with_severity(self, severity: ErrorSeverity) -> Self
pub fn with_severity(self, severity: ErrorSeverity) -> Self
Set error severity
Sourcepub fn with_category(self, category: ErrorCategory) -> Self
pub fn with_category(self, category: ErrorCategory) -> Self
Set error category
Sourcepub fn with_source_location(self, location: impl Into<String>) -> Self
pub fn with_source_location(self, location: impl Into<String>) -> Self
Add source location information
Sourcepub fn with_error_code(self, code: impl Into<String>) -> Self
pub fn with_error_code(self, code: impl Into<String>) -> Self
Add error code
Sourcepub fn add_recovery_suggestion(self, suggestion: impl Into<String>) -> Self
pub fn add_recovery_suggestion(self, suggestion: impl Into<String>) -> Self
Add a recovery suggestion
Sourcepub fn with_recovery_suggestions(self, suggestions: Vec<String>) -> Self
pub fn with_recovery_suggestions(self, suggestions: Vec<String>) -> Self
Add multiple recovery suggestions
Sourcepub fn with_cause(self, cause: ErrorContext) -> Self
pub fn with_cause(self, cause: ErrorContext) -> Self
Chain this error with a previous error
Sourcepub fn severity_string(&self) -> &'static str
pub fn severity_string(&self) -> &'static str
Get severity as string
Sourcepub fn category_string(&self) -> &'static str
pub fn category_string(&self) -> &'static str
Get category as string
Sourcepub fn is_recoverable(&self) -> bool
pub fn is_recoverable(&self) -> bool
Check if this is a recoverable error
Sourcepub fn chain_depth(&self) -> usize
pub fn chain_depth(&self) -> usize
Get the depth of the error chain
Trait Implementations§
Source§impl Clone for ErrorContext
impl Clone for ErrorContext
Source§fn clone(&self) -> ErrorContext
fn clone(&self) -> ErrorContext
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more