+ Its better than warp and rocket so far... + Also switched to 2021 Rust + Needs more refactoring but I wanted to get it to a "working" state + clippy + fmt
29 lines
686 B
Rust
29 lines
686 B
Rust
use regex::Error;
|
|
|
|
#[derive(Debug)]
|
|
pub enum RSTError {
|
|
/// Regex compile error
|
|
RegexError(regex::Error),
|
|
/// Required element not found
|
|
NotFound(&'static str),
|
|
}
|
|
|
|
impl std::error::Error for RSTError {}
|
|
|
|
impl From<regex::Error> for RSTError {
|
|
/// From regex error
|
|
fn from(e: Error) -> Self {
|
|
Self::RegexError(e)
|
|
}
|
|
}
|
|
|
|
impl std::fmt::Display for RSTError {
|
|
/// fmt error
|
|
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
|
match self {
|
|
RSTError::NotFound(s) => write!(f, "required element missing: `{}`", s),
|
|
RSTError::RegexError(e) => write!(f, "regex compile error: `{:?}`", e),
|
|
}
|
|
}
|
|
}
|