1use std::sync::mpsc::SendError;
2use std::sync::PoisonError;
3
4#[derive(Debug, thiserror::Error)]
5pub enum Error {
6 #[error(transparent)]
7 IO(#[from] std::io::Error),
8 #[error(transparent)]
9 FmtError(#[from] std::fmt::Error),
10 #[error(transparent)]
11 Serde(#[from] serde_json::Error),
12 #[cfg(all(feature = "tls", not(feature = "rustls")))]
13 #[error(transparent)]
14 TlsError(#[from] native_tls::Error),
15 #[error("sender thread stopped: {0}")]
16 SenderThreadStopped(String),
17 #[error("address resolution error: {0}:{1}")]
18 AddressResolution(String, u16),
19 #[error("fatal internal error: {0}")]
20 FatalInternal(String),
21 #[cfg(all(not(feature = "tls"), feature = "rustls"))]
22 #[error("rustls client: {0}")]
23 InvalidDNSName(#[from] rustls_crate::client::InvalidDnsNameError),
24 #[cfg(all(not(feature = "tls"), feature = "rustls"))]
25 #[error("rustls: {0}")]
26 Rustls(#[from] rustls_crate::Error),
27}
28
29impl<T> From<PoisonError<T>> for Error {
30 fn from(err: PoisonError<T>) -> Self {
31 Self::FatalInternal(err.to_string())
32 }
33}
34
35impl<T> From<SendError<T>> for Error {
36 fn from(err: SendError<T>) -> Self {
37 Self::SenderThreadStopped(err.to_string())
38 }
39}