Skip to main content

jns42_lib/
errors.rs

1#[derive(Clone, Debug, PartialEq, PartialOrd, Eq, Ord)]
2pub struct ValidationError {
3  r#type: &'static str,
4}
5
6impl std::error::Error for ValidationError {}
7
8impl ValidationError {
9  pub fn new(r#type: &'static str) -> Self {
10    Self { r#type }
11  }
12}
13
14impl core::fmt::Display for ValidationError {
15  fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
16    write!(f, "validation error for type {}", self.r#type)
17  }
18}