fancy_regex_fork_pb/
error.rs1use std::fmt;
2
3pub type Result<T> = ::std::result::Result<T, Error>;
5
6#[derive(Debug, PartialEq)]
8pub enum Error {
9 ParseError,
12 UnclosedOpenParen,
14 InvalidRepeat,
16 RecursionExceeded,
18 LookBehindNotConst,
20 TrailingBackslash,
22 InvalidEscape,
24 UnclosedUnicodeName,
26 InvalidHex,
28 InvalidCodepointValue,
30 InvalidClass,
32 UnknownFlag,
34 NonUnicodeUnsupported,
36 InvalidBackref,
38 InnerError(regex::Error),
40
41 StackOverflow,
44 BacktrackLimitExceeded,
48
49 #[doc(hidden)]
52 __Nonexhaustive,
53}
54
55impl ::std::error::Error for Error {}
56
57impl fmt::Display for Error {
58 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
59 match self {
62 Error::ParseError => write!(f, "General parsing error"),
63 Error::UnclosedOpenParen => {
64 write!(f, "Opening parenthesis without closing parenthesis")
65 }
66 Error::InvalidRepeat => write!(f, "Invalid repeat syntax"),
67 Error::RecursionExceeded => write!(f, "Pattern too deeply nested"),
68 Error::LookBehindNotConst => write!(f, "Look-behind assertion without constant size"),
69 Error::TrailingBackslash => write!(f, "Backslash without following character"),
70 Error::InvalidEscape => write!(f, "Invalid escape"),
71 Error::UnclosedUnicodeName => write!(f, "Unicode escape not closed"),
72 Error::InvalidHex => write!(f, "Invalid hex escape"),
73 Error::InvalidCodepointValue => {
74 write!(f, "Invalid codepoint for hex or unicode escape")
75 }
76 Error::InvalidClass => write!(f, "Invalid character class"),
77 Error::UnknownFlag => write!(f, "Unknown group flag"),
78 Error::NonUnicodeUnsupported => write!(f, "Disabling Unicode not supported"),
79 Error::InvalidBackref => write!(f, "Invalid back reference"),
80 Error::InnerError(e) => write!(f, "Regex error: {}", e),
81 Error::StackOverflow => write!(f, "Max stack size exceeded for backtracking"),
82 Error::BacktrackLimitExceeded => write!(f, "Max limit for backtracking count exceeded"),
83 Error::__Nonexhaustive => unreachable!(),
84 }
85 }
86}