1use std::fmt;
2
3#[derive(Debug, Clone, PartialEq)]
5pub enum LinguistError {
6 InvalidPath(String),
8
9 InvalidRegex { pattern: String, error: String },
11
12 MissingNamedPattern(String),
14}
15
16impl fmt::Display for LinguistError {
17 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
18 match self {
19 LinguistError::InvalidPath(path) => {
20 write!(f, "Invalid path: {path}")
21 }
22 LinguistError::InvalidRegex { pattern, error } => {
23 write!(f, "Invalid regex pattern '{pattern}': {error}")
24 }
25 LinguistError::MissingNamedPattern(name) => {
26 write!(f, "Named pattern '{name}' not found in heuristics")
27 }
28 }
29 }
30}
31
32impl std::error::Error for LinguistError {}