pub enum DecrustError {
Show 18 variants
Io {
source: Error,
path: Option<PathBuf>,
operation: String,
backtrace: Backtrace,
},
Parse {
source: Box<dyn Error + Send + Sync + 'static>,
kind: String,
context_info: String,
backtrace: Backtrace,
},
Network {
source: Box<dyn Error + Send + Sync + 'static>,
url: Option<String>,
kind: String,
backtrace: Backtrace,
},
Config {
message: String,
path: Option<PathBuf>,
source: OptionalError,
backtrace: Backtrace,
},
Validation {
field: String,
message: String,
backtrace: Backtrace,
/* private fields */
},
Internal {
message: String,
source: OptionalError,
backtrace: Backtrace,
/* private fields */
},
CircuitBreakerOpen {
name: String,
retry_after: Option<Duration>,
backtrace: Backtrace,
/* private fields */
},
Timeout {
operation: String,
duration: Duration,
backtrace: Backtrace,
},
ResourceExhausted {
resource: String,
limit: String,
current: String,
backtrace: Backtrace,
},
NotFound {
resource_type: String,
identifier: String,
backtrace: Backtrace,
},
StateConflict {
message: String,
backtrace: Backtrace,
},
Concurrency {
message: String,
source: OptionalError,
backtrace: Backtrace,
},
ExternalService {
service_name: String,
message: String,
source: OptionalError,
backtrace: Backtrace,
},
MissingValue {
item_description: String,
backtrace: Backtrace,
},
MultipleErrors {
errors: Vec<DecrustError>,
backtrace: Backtrace,
},
WithRichContext {
context: ErrorContext,
source: Box<DecrustError>,
},
Style {
message: String,
backtrace: Backtrace,
},
Oops {
message: String,
source: Box<dyn Error + Send + Sync + 'static>,
backtrace: Backtrace,
},
}
Expand description
Unified error type for Decrust.
Variants§
Io
I/O related errors
Fields
Parse
Parsing errors (JSON, YAML, etc.)
Fields
Network
Network related errors
Fields
Config
Configuration related errors
Fields
source: OptionalError
Optional underlying error that caused the configuration issue
Validation
Validation errors
Fields
Internal
Internal errors
Fields
source: OptionalError
Optional underlying error
CircuitBreakerOpen
Circuit breaker is open
Fields
Timeout
Operation timed out
Fields
ResourceExhausted
Resource exhaustion
Fields
NotFound
Resource not found
Fields
StateConflict
State conflict
Fields
Concurrency
Concurrency related errors
Fields
source: OptionalError
Optional underlying error
ExternalService
External service errors
Fields
source: OptionalError
Optional underlying error from the external service
MissingValue
Missing value errors
Fields
MultipleErrors
Multiple errors
Fields
errors: Vec<DecrustError>
Collection of errors that occurred
WithRichContext
Error with rich context
Fields
context: ErrorContext
Rich context information attached to the error
source: Box<DecrustError>
The original error that is being wrapped with context
Style
Style and formatting errors
Fields
Oops
General purpose error wrapper
Implementations§
Source§impl DecrustError
impl DecrustError
Sourcepub fn add_context(self, context: ErrorContext) -> Self
pub fn add_context(self, context: ErrorContext) -> Self
Sourcepub fn add_context_msg(self, message: impl Into<String>) -> Self
pub fn add_context_msg(self, message: impl Into<String>) -> Self
Sourcepub fn category(&self) -> ErrorCategory
pub fn category(&self) -> ErrorCategory
Sourcepub fn severity(&self) -> ErrorSeverity
pub fn severity(&self) -> ErrorSeverity
Sourcepub fn get_rich_context(&self) -> Option<&ErrorContext>
pub fn get_rich_context(&self) -> Option<&ErrorContext>
Gets the rich context attached to this error, if any
§Returns
Some(context) if this is a WithRichContext error, None otherwise
Trait Implementations§
Source§impl AutocorrectableError for DecrustError
Implementation of AutocorrectableError for DecrustError
impl AutocorrectableError for DecrustError
Implementation of AutocorrectableError for DecrustError
This implementation enables the Decrust error system to provide intelligent autocorrection suggestions for errors that occur during application execution. It integrates with the Decrust engine to analyze errors and suggest potential fixes.
The implementation:
- Delegates autocorrection suggestion to the Decrust engine
- Accesses diagnostic information embedded within rich error contexts
- Supports the Diamond certification requirements for comprehensive error handling
Source§fn suggest_autocorrection(
&self,
decrust_engine: &Decrust,
source_code_context: Option<&str>,
) -> Option<Autocorrection>
fn suggest_autocorrection( &self, decrust_engine: &Decrust, source_code_context: Option<&str>, ) -> Option<Autocorrection>
Suggests a possible autocorrection for this error using the Decrust engine.
§Arguments
decrust_engine
- The Decrust engine instance that will analyze the errorsource_code_context
- Optional source code context that may help with generating more accurate suggestions
§Returns
An Option<Autocorrection>
containing a suggested fix, or None
if no fix can be suggested
Source§fn get_diagnostic_info(&self) -> Option<&DiagnosticResult>
fn get_diagnostic_info(&self) -> Option<&DiagnosticResult>
Retrieves diagnostic information embedded within the error if available.
This method looks for diagnostic information in errors that contain rich context, which may have been generated by compilers, linters, or other diagnostic tools.
§Returns
An Option<&DiagnosticResult>
containing diagnostic information, or None
if no such information exists
Source§impl BacktraceCompat for DecrustError
impl BacktraceCompat for DecrustError
Source§fn backtrace(&self) -> Option<&DecrustBacktrace>
fn backtrace(&self) -> Option<&DecrustBacktrace>
Source§impl Clone for DecrustError
impl Clone for DecrustError
Source§impl Debug for DecrustError
impl Debug for DecrustError
Source§impl Display for DecrustError
impl Display for DecrustError
Source§impl Error for DecrustError
impl Error for DecrustError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
Source§impl From<Box<dyn Error>> for DecrustError
Implementation of From<Box<dyn std::error::Error>> for DecrustError (non-Send+Sync version)
impl From<Box<dyn Error>> for DecrustError
Implementation of From<Box<dyn std::error::Error>> for DecrustError (non-Send+Sync version)
Source§impl From<Box<dyn Error + Send + Sync>> for DecrustError
Implementation of From<Box<dyn std::error::Error>> for DecrustError to support generic error handling
impl From<Box<dyn Error + Send + Sync>> for DecrustError
Implementation of From<Box<dyn std::error::Error>> for DecrustError to support generic error handling
Source§impl From<Error> for DecrustError
Implementation of Fromstd::io::Error for DecrustError to support extension traits
impl From<Error> for DecrustError
Implementation of Fromstd::io::Error for DecrustError to support extension traits