Enum DecrustError

Source
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

§source: Error

The underlying I/O error

§path: Option<PathBuf>

Optional path to the file or resource that caused the error

§operation: String

Description of the operation that failed

§backtrace: Backtrace

Backtrace captured at the error site

§

Parse

Parsing errors (JSON, YAML, etc.)

Fields

§source: Box<dyn Error + Send + Sync + 'static>

The underlying parsing error

§kind: String

The type of data being parsed (e.g., “JSON”, “YAML”)

§context_info: String

Additional context information about the parsing operation

§backtrace: Backtrace

Backtrace captured at the error site

§

Network

Network related errors

Fields

§source: Box<dyn Error + Send + Sync + 'static>

The underlying network error

§url: Option<String>

Optional URL that was being accessed

§kind: String

The type of network operation (e.g., “HTTP”, “TCP”)

§backtrace: Backtrace

Backtrace captured at the error site

§

Config

Configuration related errors

Fields

§message: String

Error message describing the configuration issue

§path: Option<PathBuf>

Optional path to the configuration file

§source: OptionalError

Optional underlying error that caused the configuration issue

§backtrace: Backtrace

Backtrace captured at the error site

§

Validation

Validation errors

Fields

§field: String

Name of the field that failed validation

§message: String

Description of the validation error

§backtrace: Backtrace

Backtrace captured at the error site

§

Internal

Internal errors

Fields

§message: String

Description of the internal error

§source: OptionalError

Optional underlying error

§backtrace: Backtrace

Backtrace captured at the error site

§

CircuitBreakerOpen

Circuit breaker is open

Fields

§name: String

Name of the circuit breaker

§retry_after: Option<Duration>

Optional duration after which the circuit breaker might transition to half-open

§backtrace: Backtrace

Backtrace captured at the error site

§

Timeout

Operation timed out

Fields

§operation: String

Name of the operation that timed out

§duration: Duration

Duration after which the operation timed out

§backtrace: Backtrace

Backtrace captured at the error site

§

ResourceExhausted

Resource exhaustion

Fields

§resource: String

Name of the resource that was exhausted

§limit: String

The limit of the resource

§current: String

The current value that exceeded the limit

§backtrace: Backtrace

Backtrace captured at the error site

§

NotFound

Resource not found

Fields

§resource_type: String

Type of resource that was not found (e.g., “User”, “File”)

§identifier: String

Identifier of the resource that was not found

§backtrace: Backtrace

Backtrace captured at the error site

§

StateConflict

State conflict

Fields

§message: String

Description of the state conflict

§backtrace: Backtrace

Backtrace captured at the error site

§

Concurrency

Concurrency related errors

Fields

§message: String

Description of the concurrency error

§source: OptionalError

Optional underlying error

§backtrace: Backtrace

Backtrace captured at the error site

§

ExternalService

External service errors

Fields

§service_name: String

Name of the external service that caused the error

§message: String

Description of the error from the external service

§source: OptionalError

Optional underlying error from the external service

§backtrace: Backtrace

Backtrace captured at the error site

§

MissingValue

Missing value errors

Fields

§item_description: String

Description of the missing value or item

§backtrace: Backtrace

Backtrace captured at the error site

§

MultipleErrors

Multiple errors

Fields

§errors: Vec<DecrustError>

Collection of errors that occurred

§backtrace: Backtrace

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

§message: String

The style error message

§backtrace: Backtrace

Backtrace captured at the error site

§

Oops

General purpose error wrapper

Fields

§message: String

Custom error message

§source: Box<dyn Error + Send + Sync + 'static>

The underlying error being wrapped

§backtrace: Backtrace

Backtrace captured at the error site

Implementations§

Source§

impl DecrustError

Source

pub fn add_context(self, context: ErrorContext) -> Self

Adds rich context to an error

This wraps the error in a WithRichContext variant, which allows for additional information to be attached to the error.

§Parameters
  • context - The error context to add
§Returns

A new error with the context attached

Source

pub fn add_context_msg(self, message: impl Into<String>) -> Self

Adds a simple message context to an error

This is a convenience method that creates a simple ErrorContext with just a message and adds it to the error.

§Parameters
  • message - The message to add as context
§Returns

A new error with the context attached

Source

pub fn category(&self) -> ErrorCategory

Gets the category of this error

§Returns

The ErrorCategory that best describes this error

Source

pub fn severity(&self) -> ErrorSeverity

Gets the severity of this error

§Returns

The ErrorSeverity level of this error

Source

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

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:

  1. Delegates autocorrection suggestion to the Decrust engine
  2. Accesses diagnostic information embedded within rich error contexts
  3. Supports the Diamond certification requirements for comprehensive error handling
Source§

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 error
  • source_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>

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

Source§

fn backtrace(&self) -> Option<&DecrustBacktrace>

Get the backtrace associated with this error, if any
Source§

impl Clone for DecrustError

Source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for DecrustError

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for DecrustError

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Error for DecrustError

Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0: use the Display impl or to_string()
1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0: replaced by Error::source, which can support downcasting
Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl From<Box<dyn Error>> for DecrustError

Implementation of From<Box<dyn std::error::Error>> for DecrustError (non-Send+Sync version)

Source§

fn from(err: Box<dyn Error>) -> Self

Converts to this type from the input type.
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

Source§

fn from(err: Box<dyn Error + Send + Sync + 'static>) -> Self

Converts to this type from the input type.
Source§

impl From<Error> for DecrustError

Implementation of Fromstd::io::Error for DecrustError to support extension traits

Source§

fn from(err: Error) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for DecrustError

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<E> BacktraceProvider for E

Source§

fn get_deepest_backtrace(&self) -> Option<&DecrustBacktrace>

Get a backtrace from this error or any of its sources
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more