Skip to main content

zenith_layout/
error.rs

1//! Error types for zenith-layout.
2
3/// An error produced by the text-layout layer.
4#[derive(Debug, Clone, PartialEq)]
5pub struct LayoutError {
6    /// Human-readable description of what went wrong.
7    pub message: String,
8}
9
10impl LayoutError {
11    /// Construct a `LayoutError` with the given message.
12    pub fn new(message: impl Into<String>) -> Self {
13        Self {
14            message: message.into(),
15        }
16    }
17}
18
19impl std::fmt::Display for LayoutError {
20    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
21        write!(f, "{}", self.message)
22    }
23}
24
25impl std::error::Error for LayoutError {}