Skip to main content

sealed_surface/
error.rs

1//! Crate error type.
2
3use std::fmt;
4
5/// Recoverable failure from layout, lens, or encode.
6#[derive(Debug, Clone, PartialEq, Eq)]
7#[non_exhaustive]
8pub enum Error {
9    /// Grid has no columns or a row width that does not match the schema.
10    InvalidGrid(&'static str),
11    /// Requested layout is reserved but not implemented.
12    UnsupportedLayout(&'static str),
13    /// PNG / pixmap dimensions are unusable.
14    Raster(&'static str),
15}
16
17impl fmt::Display for Error {
18    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
19        match self {
20            Self::InvalidGrid(msg) => write!(f, "invalid grid: {msg}"),
21            Self::UnsupportedLayout(name) => write!(f, "unsupported layout: {name}"),
22            Self::Raster(msg) => write!(f, "raster: {msg}"),
23        }
24    }
25}
26
27impl std::error::Error for Error {}