1use std::{io, path::PathBuf};
4
5#[derive(Clone, Debug, thiserror::Error)]
7pub enum ConfigError {
8 #[error("`{0}` does not exist.")]
10 DoesNotExist(PathBuf),
11
12 #[error("`{0}` is not a file.")]
14 NotAFile(PathBuf),
15
16 #[error("Input error `{1}` while trying to read the contents of `{0}`.")]
18 IoError(PathBuf, io::ErrorKind),
19
20 #[error("Could not parse the contents of `{0}`. {1}.")]
22 DeserializationError(PathBuf, String),
23
24 #[error(
26 "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."
27 )]
28 RegexError { name: String, value: String },
29
30 #[error(
33 "Unknown lint type: `{0}`. Please double check the spelling, or consult the documentation for all the available lint codes."
34 )]
35 UnknownLintCode(String),
36}
37
38#[derive(Debug, thiserror::Error, Clone)]
40pub enum ProjectPathError {
41 #[error(
42 "Cannot canonicalize path `{0}`. Path does not exist or an internal component is not a directory. Please double-check that the path provided is correct."
43 )]
44 CanonicalizationError(PathBuf),
45
46 #[error("Path `{0}` is outside the project directory and does not need to be ignored.")]
47 PathNotWithinProject(PathBuf),
48
49 #[error(
50 "Ignored path `{0}` is a protected root directory. If you'd like to disable a root directory, set it to \"\" in the configuration file."
51 )]
52 IgnoringProtectedPath(PathBuf),
53}