pub struct ErrorContext {
pub message: String,
pub source_location: Option<ErrorSource>,
pub recovery_suggestion: Option<String>,
pub metadata: HashMap<String, String>,
pub severity: ErrorSeverity,
pub timestamp: Option<SystemTime>,
pub correlation_id: Option<String>,
pub component: Option<String>,
pub tags: Vec<String>,
pub diagnostic_info: Option<DiagnosticResult>,
}
Expand description
Additional structured context for an error
Fields§
§message: String
Main error message
source_location: Option<ErrorSource>
Source location information for the error
recovery_suggestion: Option<String>
Optional suggestion for how to recover from the error
metadata: HashMap<String, String>
Additional key-value metadata associated with the error
severity: ErrorSeverity
Severity level of the error
timestamp: Option<SystemTime>
Timestamp when the error occurred
correlation_id: Option<String>
Correlation ID for tracking related errors across systems
component: Option<String>
Component or subsystem where the error occurred
Tags for categorizing or filtering errors
diagnostic_info: Option<DiagnosticResult>
Detailed diagnostic information if available
Implementations§
Source§impl ErrorContext
impl ErrorContext
Sourcepub fn new(message: impl Into<String>) -> ErrorContext
pub fn new(message: impl Into<String>) -> ErrorContext
Sourcepub fn with_severity(self, severity: ErrorSeverity) -> ErrorContext
pub fn with_severity(self, severity: ErrorSeverity) -> ErrorContext
Sourcepub fn with_source_location(self, source_location: ErrorSource) -> ErrorContext
pub fn with_source_location(self, source_location: ErrorSource) -> ErrorContext
Adds source location information to the error context
§Parameters
source_location
- Source location information
Sourcepub fn with_recovery_suggestion(
self,
suggestion: impl Into<String>,
) -> ErrorContext
pub fn with_recovery_suggestion( self, suggestion: impl Into<String>, ) -> ErrorContext
Adds a recovery suggestion to the error context
§Parameters
suggestion
- Suggestion for how to recover from the error
Sourcepub fn with_metadata(
self,
key: impl Into<String>,
value: impl Into<String>,
) -> ErrorContext
pub fn with_metadata( self, key: impl Into<String>, value: impl Into<String>, ) -> ErrorContext
Adds a metadata key-value pair to the error context
§Parameters
key
- Metadata keyvalue
- Metadata value
Sourcepub fn with_correlation_id(self, id: impl Into<String>) -> ErrorContext
pub fn with_correlation_id(self, id: impl Into<String>) -> ErrorContext
Adds a correlation ID to the error context
§Parameters
id
- Correlation ID for tracking related errors
Sourcepub fn with_component(self, component: impl Into<String>) -> ErrorContext
pub fn with_component(self, component: impl Into<String>) -> ErrorContext
Adds a component name to the error context
§Parameters
component
- Component or subsystem where the error occurred
Sourcepub fn add_tag(self, tag: impl Into<String>) -> ErrorContext
pub fn add_tag(self, tag: impl Into<String>) -> ErrorContext
Sourcepub fn with_diagnostic_info(self, diagnostic: DiagnosticResult) -> ErrorContext
pub fn with_diagnostic_info(self, diagnostic: DiagnosticResult) -> ErrorContext
Adds detailed diagnostic information to the error context
§Parameters
diagnostic
- Detailed diagnostic information
Sourcepub fn with_location(self, location: Location) -> ErrorContext
pub fn with_location(self, location: Location) -> ErrorContext
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 more