2022-06-15 05:25:05 +02:00
|
|
|
use std::path::PathBuf;
|
|
|
|
|
|
|
|
use miette::Diagnostic;
|
|
|
|
use thiserror::Error;
|
|
|
|
|
|
|
|
#[derive(Debug, Error, Diagnostic)]
|
|
|
|
#[non_exhaustive]
|
|
|
|
pub enum Error {
|
|
|
|
/// Error received when an [`IgnoreFile`] cannot be read.
|
|
|
|
///
|
|
|
|
/// [`IgnoreFile`]: crate::IgnoreFile
|
|
|
|
#[error("cannot read ignore '{file}': {err}")]
|
|
|
|
#[diagnostic(code(ignore_file::read))]
|
|
|
|
Read {
|
|
|
|
/// The path to the erroring ignore file.
|
|
|
|
file: PathBuf,
|
|
|
|
|
|
|
|
/// The underlying error.
|
|
|
|
#[source]
|
|
|
|
err: std::io::Error,
|
|
|
|
},
|
|
|
|
|
|
|
|
/// Error received when parsing a glob fails.
|
|
|
|
#[error("cannot parse glob from ignore '{file:?}': {err}")]
|
|
|
|
#[diagnostic(code(ignore_file::glob))]
|
|
|
|
Glob {
|
|
|
|
/// The path to the erroring ignore file.
|
|
|
|
file: Option<PathBuf>,
|
|
|
|
|
|
|
|
/// The underlying error.
|
|
|
|
#[source]
|
|
|
|
err: ignore::Error,
|
|
|
|
// TODO: extract glob error into diagnostic
|
|
|
|
},
|
|
|
|
|
2023-03-18 11:23:46 +01:00
|
|
|
/// Multiple related [`Error`](enum@Error)s.
|
2022-06-15 05:25:05 +02:00
|
|
|
#[error("multiple: {0:?}")]
|
|
|
|
#[diagnostic(code(ignore_file::set))]
|
|
|
|
Multi(#[related] Vec<Error>),
|
|
|
|
}
|