Skip to main content

ferritin_core/model/
error.rs

1//! Validation errors for molecular model construction.
2
3use std::fmt;
4
5/// An invariant violation encountered while constructing a molecular model.
6#[derive(Clone, Debug, PartialEq, Eq)]
7pub struct ModelError {
8    message: String,
9}
10
11impl ModelError {
12    pub(crate) fn new(message: impl Into<String>) -> Self {
13        Self {
14            message: message.into(),
15        }
16    }
17}
18
19impl fmt::Display for ModelError {
20    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
21        f.write_str(&self.message)
22    }
23}
24
25impl std::error::Error for ModelError {}