Skip to main content

limnifs_write/config/
error.rs

1//! Configuration errors.
2
3#![allow(clippy::module_name_repetitions)]
4
5use std::io;
6
7/// Errors that can occur when loading or validating a `WriteConfig`.
8#[derive(Debug, thiserror::Error)]
9pub enum ConfigError {
10    /// I/O error when reading the config file.
11    #[error("I/O error reading config: {0}")]
12    Io(#[from] io::Error),
13
14    /// TOML parse error.
15    #[error("TOML parse error: {0}")]
16    Toml(#[from] toml::de::Error),
17
18    /// TOML serialisation error.
19    #[error("TOML serialise error: {0}")]
20    TomlSer(#[from] toml::ser::Error),
21
22    /// A field value is out of range or violates a relation.
23    #[error("invalid value for {field}: {reason}")]
24    InvalidValue {
25        /// Field name (e.g. `"chunking.min_chunk_size"`).
26        field: String,
27        /// Why it's invalid.
28        reason: String,
29    },
30
31    /// A categorizer name appears more than once.
32    #[error("duplicate categorizer name: {0}")]
33    DuplicateCategorizer(String),
34
35    /// A codec name is not in the registry.
36    #[error("unknown codec: {0}")]
37    UnknownCodec(String),
38}