1 | /// An error that occurred during parsing or compiling a regular expression. |
2 | /// |
3 | /// A parse error occurs when the syntax of the regex pattern is not |
4 | /// valid. Otherwise, a regex can still fail to build if it would |
5 | /// result in a machine that exceeds the configured size limit, via |
6 | /// [`RegexBuilder::size_limit`](crate::RegexBuilder::size_limit). |
7 | /// |
8 | /// This error type provides no introspection capabilities. The only thing you |
9 | /// can do with it is convert it to a string as a human readable error message. |
10 | #[derive (Clone, Debug, Eq, PartialEq)] |
11 | pub struct Error { |
12 | msg: &'static str, |
13 | } |
14 | |
15 | impl Error { |
16 | pub(crate) fn new(msg: &'static str) -> Error { |
17 | Error { msg } |
18 | } |
19 | } |
20 | |
21 | #[cfg (feature = "std" )] |
22 | impl std::error::Error for Error {} |
23 | |
24 | impl core::fmt::Display for Error { |
25 | fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { |
26 | write!(f, " {}" , self.msg) |
27 | } |
28 | } |
29 | |