1use serde_json::Error as JsonError;
2use thiserror::Error;
3
4pub type Result<T> = std::result::Result<T, Error>;
6
7#[derive(Error, Debug)]
9#[non_exhaustive]
10pub enum Error {
11 #[error(transparent)]
13 SerdeJson(#[from] JsonError),
14
15 #[error("Unsupported room version: {0}")]
17 Unsupported(String),
18
19 #[error("Not found error: {0}")]
21 NotFound(String),
22
23 #[error("Invalid PDU: {0}")]
25 InvalidPdu(String),
26
27 #[error("{0}")]
29 Custom(Box<dyn std::error::Error>),
30}
31
32impl Error {
33 pub fn custom<E: std::error::Error + 'static>(e: E) -> Self {
34 Self::Custom(Box::new(e))
35 }
36}