Skip to main content

ignore_files/
error.rs

1use std::path::PathBuf;
2
3use miette::Diagnostic;
4use thiserror::Error;
5
6#[derive(Debug, Error, Diagnostic)]
7#[non_exhaustive]
8pub enum Error {
9	/// Error received when an [`IgnoreFile`] cannot be read.
10	///
11	/// [`IgnoreFile`]: crate::IgnoreFile
12	#[error("cannot read ignore '{file}': {err}")]
13	Read {
14		/// The path to the erroring ignore file.
15		file: PathBuf,
16
17		/// The underlying error.
18		#[source]
19		err: std::io::Error,
20	},
21
22	/// Error received when parsing a glob fails.
23	#[error("cannot parse glob from ignore '{file:?}': {err}")]
24	Glob {
25		/// The path to the erroring ignore file.
26		file: Option<PathBuf>,
27
28		/// The underlying error.
29		#[source]
30		err: ignore::Error,
31		// TODO: extract glob error into diagnostic
32	},
33
34	/// Multiple related [`Error`](enum@Error)s.
35	#[error("multiple: {0:?}")]
36	Multi(#[related] Vec<Error>),
37
38	/// Error received when trying to canonicalize a path
39	#[error("cannot canonicalize '{path:?}'")]
40	Canonicalize {
41		/// the path that cannot be canonicalized
42		path: PathBuf,
43
44		/// the underlying error
45		#[source]
46		err: std::io::Error,
47	},
48}