karyon_core/
error.rs

1use thiserror::Error as ThisError;
2
3pub type Result<T> = std::result::Result<T, Error>;
4
5#[derive(ThisError, Debug)]
6pub enum Error {
7    #[error(transparent)]
8    IO(#[from] std::io::Error),
9
10    #[error("TryInto Error: {0}")]
11    TryInto(String),
12
13    #[error("Timeout Error")]
14    Timeout,
15
16    #[error("Path Not Found Error: {0}")]
17    PathNotFound(String),
18
19    #[error("Event Emit Error: {0}")]
20    EventEmitError(String),
21
22    #[cfg(feature = "crypto")]
23    #[error(transparent)]
24    Ed25519(#[from] ed25519_dalek::ed25519::Error),
25
26    #[cfg(feature = "tokio")]
27    #[error(transparent)]
28    TokioJoinError(#[from] tokio::task::JoinError),
29
30    #[error("Channel Send Error: {0}")]
31    ChannelSend(String),
32
33    #[error(transparent)]
34    ChannelRecv(#[from] async_channel::RecvError),
35
36    #[error(transparent)]
37    BincodeDecode(#[from] bincode::error::DecodeError),
38
39    #[error(transparent)]
40    BincodeEncode(#[from] bincode::error::EncodeError),
41}
42
43impl<T> From<async_channel::SendError<T>> for Error {
44    fn from(error: async_channel::SendError<T>) -> Self {
45        Error::ChannelSend(error.to_string())
46    }
47}