sovran_typemap/
error.rs

1use std::fmt;
2
3/// Errors that can occur when using TypeMap
4#[derive(Debug)]
5pub enum MapError {
6    /// Failed to acquire lock on the store
7    LockError,
8    /// The requested key was not found
9    KeyNotFound(String),
10    /// Attempted to access a value with a type that doesn't match what was stored
11    TypeMismatch,
12}
13
14impl fmt::Display for MapError {
15    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
16        match self {
17            MapError::LockError => write!(f, "Failed to acquire lock"),
18            MapError::KeyNotFound(key) => write!(f, "Key not found in store: {}", key),
19            MapError::TypeMismatch => write!(f, "Type mismatch for the requested key"),
20        }
21    }
22}
23
24impl std::error::Error for MapError {}