#[non_exhaustive]pub enum ConfigError {
UnsupportedFormat(String),
MissingExtension,
MissingValue {
field: String,
span: Option<SourceSpan>,
},
TypeMismatch {
field: String,
expected: String,
found: String,
span: Option<SourceSpan>,
},
Nested {
section: String,
source: Box<dyn Diagnostic + Send + Sync>,
span: Option<SourceSpan>,
},
Io(Error),
Toml {
source: Error,
span: Option<SourceSpan>,
},
}Expand description
Unified error returned by the runtime components.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
UnsupportedFormat(String)
The format chosen by the caller or inferred from the extension is not supported.
MissingExtension
File paths without an extension cannot be parsed automatically.
MissingValue
Raised when a required value is not found during deserialization.
Fields
span: Option<SourceSpan>Optional source span for where the error occurred
TypeMismatch
Raised when a value cannot be converted into the expected target type.
Fields
span: Option<SourceSpan>Optional source span highlighting the problematic value
Nested
Used to thread contextual errors when deserializing nested structs.
Fields
source: Box<dyn Diagnostic + Send + Sync>The underlying error
span: Option<SourceSpan>Optional source span for the section
Io(Error)
IO errors propagated from the filesystem.
Toml
TOML parsing failure.
Fields
span: Option<SourceSpan>Optional source span for where the parse error occurred
Implementations§
Source§impl ConfigError
impl ConfigError
Sourcepub fn mismatch(
field: impl Into<String>,
expected: impl Into<String>,
found: impl Into<String>,
) -> Self
pub fn mismatch( field: impl Into<String>, expected: impl Into<String>, found: impl Into<String>, ) -> Self
Helper to produce a TypeMismatch error.
Sourcepub fn mismatch_at(
field: impl Into<String>,
expected: impl Into<String>,
found: impl Into<String>,
span: SourceSpan,
) -> Self
pub fn mismatch_at( field: impl Into<String>, expected: impl Into<String>, found: impl Into<String>, span: SourceSpan, ) -> Self
Helper to produce a TypeMismatch error with a source span.
Sourcepub fn nested(section: impl Into<String>, source: ConfigError) -> Self
pub fn nested(section: impl Into<String>, source: ConfigError) -> Self
Helper to wrap nested errors with additional context.
Sourcepub fn nested_at(
section: impl Into<String>,
source: ConfigError,
span: SourceSpan,
) -> Self
pub fn nested_at( section: impl Into<String>, source: ConfigError, span: SourceSpan, ) -> Self
Helper to wrap nested errors with additional context and a source span.
Sourcepub fn missing_at(key: impl Into<String>, span: SourceSpan) -> Self
pub fn missing_at(key: impl Into<String>, span: SourceSpan) -> Self
Helper to surface missing values with a source span.
Trait Implementations§
Source§impl Debug for ConfigError
impl Debug for ConfigError
Source§impl Diagnostic for ConfigError
impl Diagnostic for ConfigError
Source§fn code(&self) -> Option<Box<dyn Display + '_>>
fn code(&self) -> Option<Box<dyn Display + '_>>
Diagnostic. Ideally also globally unique, and documented
in the toplevel crate’s documentation for easy searching. Rust path
format (foo::bar::baz) is recommended, but more classic codes like
E0123 or enums will work just fine.Source§fn help(&self) -> Option<Box<dyn Display + '_>>
fn help(&self) -> Option<Box<dyn Display + '_>>
Diagnostic. Do you have any
advice for the poor soul who’s just run into this issue?Source§fn labels(&self) -> Option<Box<dyn Iterator<Item = LabeledSpan> + '_>>
fn labels(&self) -> Option<Box<dyn Iterator<Item = LabeledSpan> + '_>>
Diagnostic’s Diagnostic::source_codeSource§fn diagnostic_source(&self) -> Option<&dyn Diagnostic>
fn diagnostic_source(&self) -> Option<&dyn Diagnostic>
Source§fn severity(&self) -> Option<Severity>
fn severity(&self) -> Option<Severity>
ReportHandlers to change the display format
of this diagnostic. Read moreSource§fn url<'a>(&'a self) -> Option<Box<dyn Display + 'a>>
fn url<'a>(&'a self) -> Option<Box<dyn Display + 'a>>
Diagnostic.Source§fn source_code(&self) -> Option<&dyn SourceCode>
fn source_code(&self) -> Option<&dyn SourceCode>
Diagnostic’s Diagnostic::labels to.Diagnostics.