Skip to main content

supreme_hook_config/
error.rs

1//! The single error type shared by every disk-facing operation in this
2//! crate, loading/writing a mod's `mod.json`, the merged `HookConfig`,
3//! and the mods-directory files in [`crate::mods_dir`].
4
5use std::path::PathBuf;
6
7#[derive(Debug, thiserror::Error)]
8pub enum HookConfigError {
9    #[error("failed to read hook config from {path}: {source}")]
10    Read {
11        path: PathBuf,
12        #[source]
13        source: std::io::Error,
14    },
15    #[error("failed to write hook config to {path}: {source}")]
16    Write {
17        path: PathBuf,
18        #[source]
19        source: std::io::Error,
20    },
21    #[error("failed to parse hook config: {0}")]
22    Parse(#[from] serde_json::Error),
23    #[error("mod config at {path} failed validation: {reasons}")]
24    Invalid { path: PathBuf, reasons: String },
25}