1use regex::Error as RegexError;
10
11use crate::token_filter::SynonymFileError;
12
13#[derive(Debug, thiserror::Error)]
15pub enum AnalysisError {
16 #[error("invalid {component} regular expression `{pattern}`: {source}")]
17 InvalidRegex {
18 component: &'static str,
19 pattern: String,
20 #[source]
21 source: RegexError,
22 },
23 #[error("failed to initialize built-in {component} regular expression: {message}")]
24 BuiltInRegex {
25 component: &'static str,
26 message: String,
27 },
28 #[error(
29 "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})"
30 )]
31 InvalidGramBounds {
32 component: &'static str,
33 min_gram: usize,
34 max_gram: usize,
35 },
36 #[error(transparent)]
37 SynonymFile(#[from] SynonymFileError),
38}
39
40pub type AnalysisResult<T> = std::result::Result<T, AnalysisError>;