1use thiserror::Error;
2
3#[derive(Debug, Error)]
5#[non_exhaustive]
6pub enum OneIoError {
7 #[error("IO error: {0}")]
9 Io(#[from] std::io::Error),
10
11 #[error("{0}")]
13 Network(Box<dyn std::error::Error + Send + Sync>),
14
15 #[error("{url}: {source}")]
17 NetworkWithContext {
18 source: Box<dyn std::error::Error + Send + Sync>,
19 url: String,
20 },
21
22 #[error("{service} status error: {code}")]
24 Status { service: &'static str, code: u16 },
25
26 #[error("Invalid header: {0}")]
28 InvalidHeader(String),
29
30 #[error("Invalid certificate: {0}")]
32 InvalidCertificate(String),
33
34 #[error("Not supported: {0}")]
36 NotSupported(String),
37}
38
39#[cfg(feature = "http")]
41impl From<reqwest::Error> for OneIoError {
42 fn from(err: reqwest::Error) -> Self {
43 OneIoError::Network(Box::new(err))
44 }
45}
46
47#[cfg(feature = "ftp")]
48impl From<suppaftp::FtpError> for OneIoError {
49 fn from(err: suppaftp::FtpError) -> Self {
50 OneIoError::Network(Box::new(err))
51 }
52}
53
54#[cfg(feature = "json")]
55impl From<serde_json::Error> for OneIoError {
56 fn from(err: serde_json::Error) -> Self {
57 OneIoError::Network(Box::new(err))
58 }
59}
60
61#[cfg(feature = "s3")]
62impl From<s3::error::S3Error> for OneIoError {
63 fn from(err: s3::error::S3Error) -> Self {
64 OneIoError::Network(Box::new(err))
65 }
66}
67
68#[cfg(feature = "s3")]
69impl From<s3::creds::error::CredentialsError> for OneIoError {
70 fn from(err: s3::creds::error::CredentialsError) -> Self {
71 OneIoError::Network(Box::new(err))
72 }
73}
74
75#[cfg(feature = "s3")]
76impl From<s3::region::error::RegionError> for OneIoError {
77 fn from(err: s3::region::error::RegionError) -> Self {
78 OneIoError::Network(Box::new(err))
79 }
80}