libscilo/config/
error.rs

1//! Errors that can be raised during the parsing of a [`ConfigFile`][crate::config::file::ConfigFile].
2
3use std::{io, path::PathBuf};
4
5/// Errors that can be raised during the parsing of a [`ConfigFile`][crate::config::file::ConfigFile].
6#[derive(Clone, Debug, thiserror::Error)]
7pub enum ConfigError {
8    /// The configuration file specified by the user cannot be found.
9    #[error("`{0}` does not exist.")]
10    DoesNotExist(PathBuf),
11
12    /// The configuration file specified by the user is not a file that can be parsed.
13    #[error("`{0}` is not a file.")]
14    NotAFile(PathBuf),
15
16    /// Parsing the user's configuration file failed for some reason.
17    #[error("Input error `{1}` while trying to read the contents of `{0}`.")]
18    IoError(PathBuf, io::ErrorKind),
19
20    /// Parsing the user's configuration file failed for some reason.
21    #[error("Could not parse the contents of `{0}`. {1}.")]
22    DeserializationError(PathBuf, String),
23
24    /// The regular expression written by the user is not a valid regular expression.
25    #[error("Regular expression `{value}` for `{name}` produced an error. Please check that this value is a valid regular expression. See https://docs.rs/regex/latest/regex/#examples for examples.")]
26    RegexError { name: String, value: String },
27
28    /// The lint code written by the user does not match one of the variants of
29    /// [`LintCheck`][crate::lints::LintCheck].
30    #[error("Unknown lint type: `{0}`. Please double check the spelling, or consult the documentation for all the available lint codes.")]
31    UnknownLintCode(String),
32}