use core::fmt;
#[derive(Debug)]
pub enum Error {
#[cfg(feature = "regex")]
InvalidRegex {
pattern: String,
source: regex::Error,
},
}
impl fmt::Display for Error {
fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result {
#[cfg(feature = "regex")]
{
match self {
Error::InvalidRegex { pattern, source } => {
write!(_f, "invalid regex pattern `{pattern}`: {source}")
}
}
}
#[cfg(not(feature = "regex"))]
{
match *self {}
}
}
}
impl std::error::Error for Error {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
#[cfg(feature = "regex")]
{
match self {
Error::InvalidRegex { source, .. } => Some(source),
}
}
#[cfg(not(feature = "regex"))]
{
match *self {}
}
}
}