use std::{convert::Infallible, error::Error};
use thiserror::Error;
#[derive(Debug, Error)]
pub enum BastehError {
#[error("BastehError: Method not supported for the Basteh backend provided")]
MethodNotSupported,
#[error("BastehError: Value is not a valid number or mutation will result in overflow")]
InvalidNumber,
#[error("BastehError: Invalid type requested from backend")]
TypeConversion,
#[error("BastehError: {:?}", self)]
Custom(Box<dyn Error + Send>),
}
impl BastehError {
pub fn custom<E>(err: E) -> Self
where
E: 'static + Error + Send,
{
Self::Custom(Box::new(err))
}
}
impl From<Infallible> for BastehError {
fn from(_value: Infallible) -> Self {
BastehError::MethodNotSupported
}
}
pub type Result<T> = std::result::Result<T, BastehError>;