//! Error types for memex.

use std::fmt;

/// Errors that can occur during memex operations.
#[derive(Debug)]
pub enum MemexError {
    /// An invalid layout name was specified.
    InvalidLayout {
        /// The invalid layout string that was provided
        layout: String,
    },
}

impl fmt::Display for MemexError {
    /// Render a human-readable description for memex errors.
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        match self {
            MemexError::InvalidLayout { layout } => {
                write!(
                    f,
                    "unsupported layout `{}`; expected `module-tree` or `module-single`",
                    layout
                )
            }
        }
    }
}

impl std::error::Error for MemexError {}
