Error

Enum Error 

Source
pub enum Error {
    Parse {
        message: String,
        line: usize,
        column: usize,
        file: Option<String>,
    },
    UnknownFormat {
        format: String,
    },
    KeyNotFound {
        key: String,
        available: Vec<String>,
    },
    Type {
        value: String,
        expected_type: String,
        actual_type: String,
    },
    Io {
        path: String,
        source: Error,
    },
    Validation {
        message: String,
    },
    General {
        message: String,
    },
    FeatureNotEnabled {
        feature: String,
    },
    Concurrency {
        message: String,
    },
    Noml {
        source: NomlError,
    },
    Internal {
        message: String,
        context: Option<String>,
    },
}
Expand description

Comprehensive error types for all config-lib operations.

This error system provides maximum clarity about what went wrong, where it happened, and how to fix it. Each variant includes enough context for both developers and end users to understand and resolve issues.

Variants§

§

Parse

Parsing errors - when the input cannot be parsed due to syntax issues

Fields

§message: String

Human-readable error message

§line: usize

Line number where error occurred (1-indexed)

§column: usize

Column number where error occurred (1-indexed)

§file: Option<String>

File path where error occurred (if applicable)

§

UnknownFormat

Format detection errors

Fields

§format: String

The format that couldn’t be detected/parsed

§

KeyNotFound

Key access errors - when requesting non-existent keys

Fields

§key: String

The key that was requested

§available: Vec<String>

Available keys at that level (for suggestions)

§

Type

Type conversion errors - when values cannot be converted to requested type

Fields

§value: String

The value that couldn’t be converted

§expected_type: String

The expected type

§actual_type: String

The actual type found

§

Io

File I/O errors - wraps std::io::Error with additional context

Fields

§path: String

Path to the file that caused the error

§source: Error

The underlying I/O error

§

Validation

General validation errors

Fields

§message: String

Description of the validation error

§

General

Generic error for other cases

Fields

§message: String

Generic error message

§

FeatureNotEnabled

Feature not enabled errors

Fields

§feature: String

The feature that needs to be enabled

§

Concurrency

Concurrency errors - lock failures, thread synchronization issues

Fields

§message: String

Description of the concurrency error

§

Noml

NOML library errors (when using NOML format)

Fields

§source: NomlError

The underlying NOML error

§

Internal

Internal errors - these should never happen in normal operation

Fields

§message: String

Description of the internal error

§context: Option<String>

Optional context about where this occurred

Implementations§

Source§

impl Error

Source

pub fn parse(message: impl Into<String>, line: usize, column: usize) -> Self

Create a parse error with position information

Source

pub fn parse_with_file( message: impl Into<String>, line: usize, column: usize, file: impl Into<String>, ) -> Self

Create a parse error with file context

Source

pub fn key_not_found(key: impl Into<String>) -> Self

Create a key not found error

Source

pub fn key_not_found_with_suggestions( key: impl Into<String>, available: Vec<String>, ) -> Self

Create a key not found error with suggestions

Source

pub fn type_error( value: impl Into<String>, expected: impl Into<String>, actual: impl Into<String>, ) -> Self

Create a type conversion error

Source

pub fn io(path: impl Into<String>, source: Error) -> Self

Create an I/O error with file context

Source

pub fn unknown_format(format: impl Into<String>) -> Self

Create an unknown format error

Source

pub fn feature_not_enabled(feature: impl Into<String>) -> Self

Create a feature not enabled error

Source

pub fn concurrency(message: impl Into<String>) -> Self

Create a concurrency error

Source

pub fn serialize(message: impl Into<String>) -> Self

Create a serialization error

Source

pub fn validation(message: impl Into<String>) -> Self

Create a validation error

Source

pub fn general(message: impl Into<String>) -> Self

Create a general error

Source

pub fn internal(message: impl Into<String>) -> Self

Create an internal error

Source

pub fn internal_with_context( message: impl Into<String>, context: impl Into<String>, ) -> Self

Create an internal error with context

Trait Implementations§

Source§

impl Debug for Error

Source§

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

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

impl Display for Error

Source§

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

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

impl Error for Error

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<Error> for Error

Convert from std::io::Error

Source§

fn from(source: Error) -> Self

Converts to this type from the input type.
Source§

impl From<NomlError> for Error

Source§

fn from(source: NomlError) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl Freeze for Error

§

impl !RefUnwindSafe for Error

§

impl Send for Error

§

impl Sync for Error

§

impl Unpin for Error

§

impl !UnwindSafe for Error

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<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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> 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.