use serde_json::Error as JsonError;
use thiserror::Error;
pub type Result<T> = std::result::Result<T, Error>;
#[derive(Error, Debug)]
#[non_exhaustive]
pub enum Error {
#[error(transparent)]
SerdeJson(#[from] JsonError),
#[error("Unsupported room version: {0}")]
Unsupported(String),
#[error("Not found error: {0}")]
NotFound(String),
#[error("Invalid PDU: {0}")]
InvalidPdu(String),
#[error("{0}")]
Custom(Box<dyn std::error::Error>),
}
impl Error {
pub fn custom<E: std::error::Error + 'static>(e: E) -> Self {
Self::Custom(Box::new(e))
}
}