Skip to main content

melior_macro/dialect/error/
ods.rs

1use std::{
2    error::Error,
3    fmt::{self, Display, Formatter},
4};
5
6#[derive(Debug)]
7pub enum OdsError {
8    ExpectedSuperClass(&'static str),
9    InvalidTrait,
10    UnexpectedSuperClass(&'static str),
11}
12
13impl Display for OdsError {
14    fn fmt(&self, formatter: &mut Formatter) -> fmt::Result {
15        match self {
16            Self::ExpectedSuperClass(class) => {
17                write!(formatter, "record should be a sub-class of {class}",)
18            }
19            Self::InvalidTrait => write!(formatter, "record is not a supported trait"),
20            Self::UnexpectedSuperClass(class) => {
21                write!(formatter, "record should not be a sub-class of {class}",)
22            }
23        }
24    }
25}
26
27impl Error for OdsError {}