Skip to main content

keyhog_scanner/
error.rs

1//! Specialized error types for the scanner engine.
2
3use thiserror::Error;
4
5#[derive(Debug, Error)]
6/// Errors returned while compiling detector patterns into a scanner.
7pub enum ScanError {
8    #[error(
9        "failed to compile regex for detector {detector_id} pattern {index}: {source}. Fix: correct the detector regex or capture group configuration"
10    )]
11    RegexCompile {
12        detector_id: String,
13        index: usize,
14        source: regex::Error,
15    },
16    #[error(
17        "failed to compile scanner regex set: {0}. Fix: simplify the detector regex set or remove the invalid pattern"
18    )]
19    RegexSetCompile(#[from] regex::Error),
20    #[error(
21        "failed to build Aho-Corasick literal matcher: {0}. Fix: check for empty or invalid detector keywords"
22    )]
23    AhoCorasick(#[from] aho_corasick::BuildError),
24    #[error("GPU scanner failure: {0}")]
25    Gpu(String),
26    #[error("SIMD scanner failure: {0}")]
27    Simd(String),
28}
29
30/// Specialized Result type for scanning operations.
31pub type Result<T> = std::result::Result<T, ScanError>;