arete_sdk/
error.rs

1use std::{sync::PoisonError, time::SystemTimeError};
2
3#[derive(Debug)]
4pub enum Error {
5    Default(String),
6    Io(String),
7    Lock(String),
8    Serialization(String),
9    Timeout(String),
10}
11
12impl<T> From<PoisonError<T>> for Error {
13    fn from(e: PoisonError<T>) -> Self {
14        Self::Lock(e.to_string())
15    }
16}
17
18impl From<serde_json::Error> for Error {
19    fn from(e: serde_json::Error) -> Self {
20        Error::Serialization(e.to_string())
21    }
22}
23
24impl From<std::io::Error> for Error {
25    fn from(e: std::io::Error) -> Self {
26        Error::Io(e.to_string())
27    }
28}
29
30impl From<SystemTimeError> for Error {
31    fn from(e: SystemTimeError) -> Self {
32        Error::Default(e.to_string())
33    }
34}
35
36impl From<tungstenite::Error> for Error {
37    fn from(e: tungstenite::Error) -> Self {
38        Error::Io(e.to_string())
39    }
40}