website/src/rst_parser/rst_error.rs
Joey Hines 33a6056445 Updated website to use axum
+ 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
2022-12-26 17:17:40 -06:00

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),
}
}
}