use regex::Error as RegexError;
use crate::token_filter::SynonymFileError;
#[derive(Debug, thiserror::Error)]
pub enum AnalysisError {
#[error("invalid {component} regular expression `{pattern}`: {source}")]
InvalidRegex {
component: &'static str,
pattern: String,
#[source]
source: RegexError,
},
#[error("failed to initialize built-in {component} regular expression: {message}")]
BuiltInRegex {
component: &'static str,
message: String,
},
#[error(
"invalid {component} gram bounds: min_gram must be at least 1 and max_gram must be greater than or equal to min_gram (got {min_gram}..={max_gram})"
)]
InvalidGramBounds {
component: &'static str,
min_gram: usize,
max_gram: usize,
},
#[error(transparent)]
SynonymFile(#[from] SynonymFileError),
}
pub type AnalysisResult<T> = std::result::Result<T, AnalysisError>;