#[non_exhaustive]pub enum FernError {
Config(ConfigError),
Io {
message: String,
source: Error,
},
Watch {
message: String,
},
Ipc {
message: String,
},
}Expand description
The top-level error type for all fernctl operations.
FernError is an enum that wraps all specific error types in the crate.
It implements [miette::Diagnostic] for rich error reporting and
Notifiable for desktop notification integration.
§Error Categories
| Variant | Description | Typical Cause |
|---|---|---|
Config | Configuration errors | Invalid TOML, bad values |
Io | File system errors | Missing files, permissions |
Watch | File watcher errors | System resource limits |
Ipc | D-Bus errors | Service not running |
§Example
use fernctl::error::{FernError, Result};
fn process_config(path: &Path) -> Result<Theme> {
let content = std::fs::read_to_string(path)
.map_err(|e| FernError::Io(e.into()))?;
let config = parse_toml(&content)?; // Returns ConfigError
Ok(config.into_theme())
}§Downcasting
You can match on specific error variants:
match result {
Err(FernError::Config(ConfigError::InvalidColor { value, .. })) => {
eprintln!("Bad color: {}", value);
}
Err(e) => eprintln!("Other error: {}", e),
Ok(theme) => { /* use theme */ }
}Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Config(ConfigError)
Configuration parsing or validation error.
This variant wraps ConfigError, which provides detailed information
about what went wrong in the configuration file.
Io
File system I/O error.
Wraps standard I/O errors with additional context about what operation was being attempted.
Fields
Watch
File watcher error.
Occurs when the file watching system fails to initialize or encounters an error while monitoring files.
Ipc
Inter-process communication error.
Occurs when communication with QuickShell via D-Bus fails.
Implementations§
Source§impl FernError
impl FernError
Sourcepub fn severity(&self) -> Severity
pub fn severity(&self) -> Severity
Returns the severity level of this error.
Severity determines how the error should be handled:
Severity::Warning— Log and continueSeverity::Error— Operation failed, but shell can continueSeverity::Fatal— Shell cannot continue
§Example
if error.severity().is_fatal() {
std::process::exit(1);
}Trait Implementations§
Source§impl Diagnostic for FernError
impl Diagnostic for FernError
Source§fn code<'a>(&'a self) -> Option<Box<dyn Display + 'a>>
fn code<'a>(&'a self) -> Option<Box<dyn Display + 'a>>
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 severity(&self) -> Option<Severity>
fn severity(&self) -> Option<Severity>
ReportHandlers to change the display format
of this diagnostic. Read moreSource§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?Source§fn source_code(&self) -> Option<&dyn SourceCode>
fn source_code(&self) -> Option<&dyn SourceCode>
Diagnostic’s [Diagnostic::labels] to.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 diagnostic_source(&self) -> Option<&dyn Diagnostic>
fn diagnostic_source(&self) -> Option<&dyn Diagnostic>
§fn url<'a>(&'a self) -> Option<Box<dyn Display + 'a>>
fn url<'a>(&'a self) -> Option<Box<dyn Display + 'a>>
Diagnostic.Diagnostics.Source§impl Error for FernError
impl Error for FernError
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 FernError
impl Notifiable for FernError
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 FernError
impl !RefUnwindSafe for FernError
impl Send for FernError
impl Sync for FernError
impl Unpin for FernError
impl !UnwindSafe for FernError
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