pub enum DecrustError {
Show 18 variants
Io {
source: Error,
path: Option<PathBuf>,
operation: String,
backtrace: DecrustBacktrace,
},
Parse {
source: Box<dyn Error + Send + Sync>,
kind: String,
context_info: String,
backtrace: DecrustBacktrace,
},
Network {
source: Box<dyn Error + Send + Sync>,
url: Option<String>,
kind: String,
backtrace: DecrustBacktrace,
},
Config {
message: String,
path: Option<PathBuf>,
source: OptionalError,
backtrace: DecrustBacktrace,
},
Validation {
field: String,
message: String,
backtrace: DecrustBacktrace,
/* private fields */
},
Internal {
message: String,
source: OptionalError,
backtrace: DecrustBacktrace,
/* private fields */
},
CircuitBreakerOpen {
name: String,
retry_after: Option<Duration>,
backtrace: DecrustBacktrace,
/* private fields */
},
Timeout {
operation: String,
duration: Duration,
backtrace: DecrustBacktrace,
},
ResourceExhausted {
resource: String,
limit: String,
current: String,
backtrace: DecrustBacktrace,
},
NotFound {
resource_type: String,
identifier: String,
backtrace: DecrustBacktrace,
},
StateConflict {
message: String,
backtrace: DecrustBacktrace,
},
Concurrency {
message: String,
source: OptionalError,
backtrace: DecrustBacktrace,
},
ExternalService {
service_name: String,
message: String,
source: OptionalError,
backtrace: DecrustBacktrace,
},
MissingValue {
item_description: String,
backtrace: DecrustBacktrace,
},
MultipleErrors {
errors: Vec<DecrustError>,
backtrace: DecrustBacktrace,
},
WithRichContext {
context: ErrorContext,
source: Box<DecrustError>,
},
Style {
message: String,
backtrace: DecrustBacktrace,
},
Oops {
message: String,
source: Box<dyn Error + Send + Sync>,
backtrace: DecrustBacktrace,
},
}
Expand description
Unified error type for Decrust.
Variants§
Io
I/O related errors
Fields
backtrace: DecrustBacktrace
Backtrace captured at the error site
Parse
Parsing errors (JSON, YAML, etc.)
Fields
backtrace: DecrustBacktrace
Backtrace captured at the error site
Network
Network related errors
Fields
backtrace: DecrustBacktrace
Backtrace captured at the error site
Config
Configuration related errors
Fields
source: OptionalError
Optional underlying error that caused the configuration issue
backtrace: DecrustBacktrace
Backtrace captured at the error site
Validation
Validation errors
Fields
backtrace: DecrustBacktrace
Backtrace captured at the error site
Internal
Internal errors
Fields
source: OptionalError
Optional underlying error
backtrace: DecrustBacktrace
Backtrace captured at the error site
CircuitBreakerOpen
Circuit breaker is open
Fields
retry_after: Option<Duration>
Optional duration after which the circuit breaker might transition to half-open
backtrace: DecrustBacktrace
Backtrace captured at the error site
Timeout
Operation timed out
Fields
backtrace: DecrustBacktrace
Backtrace captured at the error site
ResourceExhausted
Resource exhaustion
Fields
backtrace: DecrustBacktrace
Backtrace captured at the error site
NotFound
Resource not found
Fields
backtrace: DecrustBacktrace
Backtrace captured at the error site
StateConflict
State conflict
Fields
backtrace: DecrustBacktrace
Backtrace captured at the error site
Concurrency
Concurrency related errors
Fields
source: OptionalError
Optional underlying error
backtrace: DecrustBacktrace
Backtrace captured at the error site
ExternalService
External service errors
Fields
source: OptionalError
Optional underlying error from the external service
backtrace: DecrustBacktrace
Backtrace captured at the error site
MissingValue
Missing value errors
Fields
backtrace: DecrustBacktrace
Backtrace captured at the error site
MultipleErrors
Multiple errors
Fields
errors: Vec<DecrustError>
Collection of errors that occurred
backtrace: DecrustBacktrace
Backtrace captured at the error site
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
backtrace: DecrustBacktrace
Backtrace captured at the error site
Oops
General purpose error wrapper
Implementations§
Source§impl DecrustError
impl DecrustError
Sourcepub fn add_context(self, context: ErrorContext) -> DecrustError
pub fn add_context(self, context: ErrorContext) -> DecrustError
Sourcepub fn add_context_msg(self, message: impl Into<String>) -> DecrustError
pub fn add_context_msg(self, message: impl Into<String>) -> DecrustError
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§fn clone(&self) -> DecrustError
fn clone(&self) -> DecrustError
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§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