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("reqwest: {0}")]
29 Reqwest(#[from] reqwest::Error),
30 #[cfg(feature = "with-tokio")]
31 #[error("reqwest: {0}")]
32 ReqwestHeaderToStr(#[from] reqwest::header::ToStrError),
33 #[cfg(feature = "with-async-std")]
34 #[error("header to string: {0}")]
35 HeaderToStr(#[from] http::header::ToStrError),
36 #[error("from utf8: {0}")]
37 FromUtf8(#[from] std::string::FromUtf8Error),
38 #[error("serde xml: {0}")]
39 SerdeXml(#[from] quick_xml::de::DeError),
40 #[error("invalid header value: {0}")]
41 InvalidHeaderValue(#[from] http::header::InvalidHeaderValue),
42 #[cfg(any(feature = "with-async-std", feature = "with-tokio"))]
43 #[error("invalid header name: {0}")]
44 InvalidHeaderName(#[from] http::header::InvalidHeaderName),
45 #[cfg(feature = "with-async-std")]
46 #[error("surf: {0}")]
47 Surf(String),
48 #[cfg(feature = "sync")]
49 #[error("attohttpc: {0}")]
50 Atto(#[from] attohttpc::Error),
51 #[cfg(feature = "sync")]
52 #[error("attohttpc: {0}")]
53 AttoHeader(#[from] attohttpc::header::ToStrError),
54 #[cfg(feature = "sync")]
55 #[error("attohttpc: {0}")]
56 AttoHeaderName(#[from] attohttpc::header::InvalidHeaderName),
57 #[error("Could not get Write lock on Credentials")]
58 WLCredentials,
59 #[error("Could not get Read lock on Credentials")]
60 RLCredentials,
61 #[error("Time format error: {0}")]
62 TimeFormatError(#[from] time::error::Format),
63 #[error("fmt error: {0}")]
64 FmtError(#[from] std::fmt::Error),
65 #[error("serde error: {0}")]
66 SerdeError(#[from] serde_json::Error),
67 #[error("post policy error: {0}")]
68 PostPolicyError(#[from] crate::post_policy::PostPolicyError),
69 #[error("Could not get read lock on credentials")]
70 CredentialsReadLock,
71 #[error("Could not get write lock on credentials")]
72 CredentialsWriteLock,
73 #[error("xml serialization error: {0}")]
74 XmlSeError(#[from] quick_xml::SeError),
75}