use thiserror::Error;

use crate::filter::Rule;

#[derive(Error, Debug)]
pub enum Error {
    #[error("Failed to parse rule: {0:?}")]
    Pest(Box<pest::error::Error<Rule>>),
    #[error("{0}")]
    Parser(String),
    #[error("{0}")]
    Regex(#[from] regex::Error),
    #[error("{0}")]
    Unknown(String),
}

pub fn parser_error<S: AsRef<str>>(cause: S) -> Error {
    let message = format!("Failed to parse Path: {}", cause.as_ref());
    Error::Parser(message)
}
