1use thiserror::Error;
4use warpstate::Error as WarpstateError;
5
6#[derive(Debug, Error)]
7pub enum ScanError {
9 #[error(
10 "failed to compile regex for detector {detector_id} pattern {index}: {source}. Fix: correct the detector regex or capture group configuration"
11 )]
12 RegexCompile {
13 detector_id: String,
14 index: usize,
15 source: regex::Error,
16 },
17 #[error(
18 "failed to compile scanner regex set: {0}. Fix: simplify the detector regex set or remove the invalid pattern"
19 )]
20 RegexSetCompile(#[from] regex::Error),
21 #[error(
22 "failed to build warpstate automaton: {0}. Fix: reduce detector complexity or remove unsupported regex constructs"
23 )]
24 Warpstate(#[from] WarpstateError),
25 #[error(
26 "failed to build Aho-Corasick literal matcher: {0}. Fix: check for empty or invalid detector keywords"
27 )]
28 AhoCorasick(#[from] aho_corasick::BuildError),
29}
30
31pub type Result<T> = std::result::Result<T, ScanError>;