async_flow/error/
error.rs

1// This is free and unencumbered software released into the public domain.
2
3use super::{RecvError, SendError, TryRecvError, TrySendError};
4use alloc::boxed::Box;
5use thiserror::Error;
6
7pub type Result<T = (), E = Error> = core::result::Result<T, E>;
8
9#[derive(Debug, Error)]
10pub enum Error {
11    #[error("{0}")]
12    Recv(#[from] RecvError),
13
14    #[error("{0}")]
15    TryRecv(#[from] TryRecvError),
16
17    #[error("{0}")]
18    Send(#[from] SendError),
19
20    #[error("{0}")]
21    TrySend(#[from] TrySendError),
22
23    #[cfg(feature = "std")]
24    #[error("{0}")]
25    Stdio(#[from] std::io::Error),
26
27    #[error("{0}")]
28    Other(#[from] Box<dyn core::error::Error + Send + Sync>),
29}
30
31#[cfg(feature = "serde")]
32impl From<serde_json::Error> for Error {
33    fn from(value: serde_json::Error) -> Self {
34        Error::Other(Box::new(value))
35    }
36}