1use thiserror::Error;
2
3#[derive(Error, Debug)]
4#[non_exhaustive]
5pub enum S3Error {
6 #[error("Utf8 decoding error: {0}")]
7 Utf8(#[from] std::str::Utf8Error),
8 #[error("Max expiration for presigned URLs is one week, or 604.800 seconds, got {0} instead")]
9 MaxExpiry(u32),
10 #[error("Got HTTP {0} with content '{1}'")]
11 HttpFailWithBody(u16, String),
12 #[error("Http request returned a non 2** code")]
13 HttpFail,
14 #[error("aws-creds: {0}")]
15 Credentials(#[from] crate::creds::error::CredentialsError),
16 #[error("aws-region: {0}")]
17 Region(#[from] crate::region::error::RegionError),
18 #[error("sha2 invalid length: {0}")]
19 HmacInvalidLength(#[from] sha2::digest::InvalidLength),
20 #[error("url parse: {0}")]
21 UrlParse(#[from] url::ParseError),
22 #[error("io: {0}")]
23 Io(#[from] std::io::Error),
24 #[cfg(feature = "with-tokio")]
25 #[error("http: {0}")]
26 Http(#[from] http::Error),
27 #[cfg(feature = "with-tokio")]
28 #[error("hyper: {0}")]
29 Hyper(#[from] hyper::Error),
30 #[cfg(feature = "use-tokio-native-tls")]
31 #[error("native-tls: {0}")]
32 NativeTls(#[from] native_tls::Error),
33 #[error("header to string: {0}")]
34 HeaderToStr(#[from] http::header::ToStrError),
35 #[error("from utf8: {0}")]
36 FromUtf8(#[from] std::string::FromUtf8Error),
37 #[error("serde xml: {0}")]
38 SerdeXml(#[from] quick_xml::de::DeError),
39 #[error("invalid header value: {0}")]
40 InvalidHeaderValue(#[from] http::header::InvalidHeaderValue),
41 #[error("invalid header name: {0}")]
42 InvalidHeaderName(#[from] http::header::InvalidHeaderName),
43 #[cfg(feature = "with-async-std")]
44 #[error("surf: {0}")]
45 Surf(String),
46 #[cfg(feature = "sync")]
47 #[error("attohttpc: {0}")]
48 Atto(#[from] attohttpc::Error),
49 #[cfg(feature = "sync")]
50 #[error("attohttpc: {0}")]
51 AttoHeader(#[from] attohttpc::header::ToStrError),
52 #[cfg(feature = "sync")]
53 #[error("attohttpc: {0}")]
54 AttoHeaderName(#[from] attohttpc::header::InvalidHeaderName),
55 #[error("Could not get Write lock on Credentials")]
56 WLCredentials,
57 #[error("Could not get Read lock on Credentials")]
58 RLCredentials,
59 #[error("Time format error: {0}")]
60 TimeFormatError(#[from] time::error::Format),
61 #[error("fmt error: {0}")]
62 FmtError(#[from] std::fmt::Error),
63 #[error("serde error: {0}")]
64 SerdeError(#[from] serde_json::Error),
65 #[error("post policy error: {0}")]
66 PostPolicyError(#[from] crate::post_policy::PostPolicyError),
67 #[error("Could not get read lock on credentials")]
68 CredentialsReadLock,
69 #[error("Could not get write lock on credentials")]
70 CredentialsWriteLock,
71}