use std::{error::Error, fmt};
use crate::StorageError;
#[derive(Debug)]
pub enum ConnectionError {
InvalidData,
Storage(StorageError),
}
impl fmt::Display for ConnectionError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt::Debug::fmt(&self, f)
}
}
impl Error for ConnectionError {
fn source(&self) -> Option<&(dyn Error + 'static)> {
match self {
ConnectionError::Storage(e) => Some(e),
_ => None,
}
}
}
impl From<StorageError> for ConnectionError {
fn from(e: StorageError) -> Self {
Self::Storage(e)
}
}