boundless_market/storage/
error.rs1use std::error::Error as StdError;
18
19#[derive(thiserror::Error, Debug)]
21#[non_exhaustive]
22pub enum StorageError {
23 #[error("unsupported URI scheme: {0}")]
25 UnsupportedScheme(String),
26
27 #[error("invalid URL: {0}")]
29 InvalidUrl(&'static str),
30
31 #[error("URL parse error: {0}")]
33 UrlParse(#[from] url::ParseError),
34
35 #[error("size limit exceeded: {size} bytes (limit: {limit} bytes)")]
37 SizeLimitExceeded {
38 size: usize,
40 limit: usize,
42 },
43
44 #[error("IO error: {0}")]
46 Io(#[from] std::io::Error),
47
48 #[error("HTTP error: {0}")]
50 Http(#[source] Box<dyn StdError + Send + Sync + 'static>),
51
52 #[error("HTTP request failed with status: {0}")]
54 HttpStatus(u16),
55
56 #[cfg(feature = "s3")]
58 #[error("S3 error: {0}")]
59 S3(#[source] Box<dyn StdError + Send + Sync + 'static>),
60
61 #[cfg(feature = "gcs")]
63 #[error("GCS error: {0}")]
64 Gcs(#[source] Box<dyn StdError + Send + Sync + 'static>),
65
66 #[error("environment variable error: {0}")]
68 EnvVar(#[from] std::env::VarError),
69
70 #[error("missing config parameter: {0}")]
72 MissingConfig(&'static str),
73
74 #[error("no storage uploader configured")]
76 NoUploader,
77
78 #[error("{0}")]
80 Other(#[from] anyhow::Error),
81}
82
83impl StorageError {
84 pub fn http(err: impl Into<Box<dyn StdError + Send + Sync + 'static>>) -> Self {
86 Self::Http(err.into())
87 }
88
89 #[cfg(feature = "s3")]
91 pub fn s3(err: impl Into<Box<dyn StdError + Send + Sync + 'static>>) -> Self {
92 Self::S3(err.into())
93 }
94
95 #[cfg(feature = "gcs")]
97 pub fn gcs(err: impl Into<Box<dyn StdError + Send + Sync + 'static>>) -> Self {
98 Self::Gcs(err.into())
99 }
100}