honk_core/error.rs
1//! Error types for `honk-core`.
2//!
3//! A small `thiserror`-based enum to start from. Add variants as your tool
4//! grows; the CLI converts these into `anyhow::Error` automatically via the
5//! `?` operator.
6
7use thiserror::Error;
8
9/// Convenient result alias used throughout the core crate.
10pub type Result<T> = std::result::Result<T, Error>;
11
12/// Errors produced by the core crate.
13#[derive(Debug, Error)]
14pub enum Error {
15 /// An I/O operation failed (reading/writing config, etc.).
16 #[error("i/o error: {0}")]
17 Io(#[from] std::io::Error),
18
19 /// Failed to (de)serialize configuration.
20 #[error("config error: {0}")]
21 Config(String),
22
23 /// The platform did not expose a config directory.
24 #[error("could not determine the configuration directory")]
25 NoConfigDir,
26}
27
28impl From<serde_norway::Error> for Error {
29 fn from(e: serde_norway::Error) -> Self {
30 Error::Config(e.to_string())
31 }
32}