#[non_exhaustive]pub enum ConfigError {
InvalidColor {
value: String,
span: Option<SourceSpan>,
source_code: Option<String>,
},
OutOfRange {
key: String,
value: i64,
min: i64,
max: i64,
span: Option<SourceSpan>,
source_code: Option<String>,
},
UnknownKey {
key: String,
similar: Vec<String>,
span: Option<SourceSpan>,
source_code: Option<String>,
},
MissingField {
key: String,
expected_type: String,
},
TypeMismatch {
key: String,
expected: String,
actual: String,
span: Option<SourceSpan>,
source_code: Option<String>,
},
ParseError {
source: Error,
src: String,
},
InvalidTheme {
value: String,
span: Option<SourceSpan>,
source_code: Option<String>,
},
InvalidPosition {
value: String,
span: Option<SourceSpan>,
source_code: Option<String>,
},
DeprecatedKey {
key: String,
replacement: String,
removed_in: String,
span: Option<SourceSpan>,
source_code: Option<String>,
},
FontNotFound {
family: String,
},
}Expand description
Errors that occur during configuration parsing and validation.
ConfigError provides detailed, actionable error messages for configuration
problems. Each variant includes context about what went wrong and how to
fix it.
§Error Codes
Every error has a unique code (e.g., fern::config::invalid_color) that
can be looked up in documentation for detailed explanations.
§Severity Levels
Most configuration errors are Severity::Error, but some are warnings:
| Variant | Severity | Behavior |
|---|---|---|
UnknownKey | Warning | Config loads, key ignored |
DeprecatedKey | Warning | Config loads, warning shown |
| Others | Error | Config fails to load |
§Example
use fernctl::error::ConfigError;
let error = ConfigError::InvalidColor {
value: "#gg0000".to_string(),
span: None,
location: None,
};
// Rich error output with miette
println!("{:?}", miette::Report::new(error));Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
InvalidColor
Invalid color format.
The provided value is not a valid hex color. Colors must be in the
format #RRGGBB or #RRGGBBAA where each character is a hex digit.
§Valid Examples
#89b4fa— 6-digit hex (opaque)#89b4fa80— 8-digit hex (with alpha)#fff— 3-digit shorthand (expands to #ffffff)
§Invalid Examples
#gg0000— Contains non-hex characters89b4fa— Missing#prefix#89b— Invalid length (not 3, 6, or 8)
Fields
OutOfRange
Value is outside the valid range.
Numeric values must fall within specified bounds. This error indicates the value is too large or too small.
Fields
UnknownKey
Unknown configuration key.
The configuration contains a key that is not recognized. This is a warning, not an error — the configuration will still load, but the unknown key will be ignored.
§Common Causes
- Typo in key name
- Using a key from a different version
- Copy-pasting from incompatible configuration
Fields
MissingField
Required field is missing.
A required configuration field was not provided and has no default value.
TypeMismatch
Type mismatch in configuration value.
The value has the wrong type. For example, a string was provided where a number was expected.
Fields
ParseError
TOML syntax error.
The configuration file is not valid TOML. This is a fatal error because no configuration can be loaded.
Fields
source: ErrorThe underlying TOML parse error.
InvalidTheme
Invalid theme name.
The theme must be one of: “dark”, “light”, or “auto”.
Fields
InvalidPosition
Invalid bar position.
The bar position must be “top” or “bottom”.
Fields
DeprecatedKey
Deprecated configuration key.
This key still works but will be removed in a future version. This is a warning.
Fields
FontNotFound
Invalid font family.
The specified font is not available on the system.
Implementations§
Source§impl ConfigError
impl ConfigError
Sourcepub fn severity(&self) -> Severity
pub fn severity(&self) -> Severity
Returns the severity level of this error.
Most config errors are Severity::Error, but some are warnings.
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 labels(&self) -> Option<Box<dyn Iterator<Item = LabeledSpan> + '_>>
fn labels(&self) -> Option<Box<dyn Iterator<Item = LabeledSpan> + '_>>
Diagnostic’s [Diagnostic::source_code]Source§fn source_code(&self) -> Option<&dyn SourceCode>
fn source_code(&self) -> Option<&dyn SourceCode>
Diagnostic’s [Diagnostic::labels] to.§fn severity(&self) -> Option<Severity>
fn severity(&self) -> Option<Severity>
ReportHandlers to change the display format
of this diagnostic. Read more§fn help<'a>(&'a self) -> Option<Box<dyn Display + 'a>>
fn help<'a>(&'a self) -> Option<Box<dyn Display + 'a>>
Diagnostic. Do you have any
advice for the poor soul who’s just run into this issue?§fn url<'a>(&'a self) -> Option<Box<dyn Display + 'a>>
fn url<'a>(&'a self) -> Option<Box<dyn Display + 'a>>
Diagnostic.Diagnostics.§fn diagnostic_source(&self) -> Option<&dyn Diagnostic>
fn diagnostic_source(&self) -> Option<&dyn Diagnostic>
Source§impl Display for ConfigError
impl Display for ConfigError
Source§impl Error for ConfigError
impl Error for ConfigError
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<ConfigError> for FernError
impl From<ConfigError> for FernError
Source§fn from(source: ConfigError) -> Self
fn from(source: ConfigError) -> Self
Source§impl Notifiable for ConfigError
impl Notifiable for ConfigError
Source§fn suggestion(&self) -> Option<String>
fn suggestion(&self) -> Option<String>
Source§fn code(&self) -> Option<&'static str>
fn code(&self) -> Option<&'static str>
Source§fn to_notification(&self) -> Notification
fn to_notification(&self) -> Notification
Notification struct. Read moreAuto Trait Implementations§
impl Freeze for ConfigError
impl RefUnwindSafe for ConfigError
impl Send for ConfigError
impl Sync for ConfigError
impl Unpin for ConfigError
impl UnwindSafe for ConfigError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<D> OwoColorize for D
impl<D> OwoColorize for D
§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg] or
a color-specific method, such as [OwoColorize::green], Read more§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg] or
a color-specific method, such as [OwoColorize::on_yellow], Read more