Trait AsError

Source
pub trait AsError {
    // Required methods
    fn kind() -> ErrorKind;
    fn message(&self) -> String;
    fn class(&self) -> String;
    fn details(&self) -> Option<BTreeMap<String, Value>>;
}
Expand description

Trait representing a structured error with categorized information.

The AsError trait provides a standardized way to define and retrieve detailed error information, including its kind, message, classification, and additional details.

Implementing this trait allows for better error management and debugging by ensuring consistency in error structures.

Required Methods§

Source

fn kind() -> ErrorKind

The kind of error.

The error kind represents a categorized type of error, allowing consumers to handle different error types distinctly.

Source

fn message(&self) -> String

The error message.

This message provides a human-readable description of the error.

Source

fn class(&self) -> String

The class or category of the error.

The class helps in further classifying errors, providing an additional layer of categorization beyond ErrorKind.

Source

fn details(&self) -> Option<BTreeMap<String, Value>>

Additional details related to the error.

This method provides an optional key-value mapping of extra data associated with the error, which can be useful for debugging or logging purposes.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§