use thiserror::Error;
use super::url::Scheme;
#[derive(Debug, Error)]
pub enum StorageError {
#[error("invalid storage URL '{input}': {reason}")]
InvalidUrl {
input: String,
reason: String,
},
#[error(
"storage scheme {scheme:?} is not enabled in this build. \
Rebuild with the matching cargo feature (storage-s3 / storage-gcs / \
storage-azure) to enable it."
)]
SchemeNotEnabled {
scheme: Scheme,
},
#[error("driver init failed for {scheme:?}: {reason}")]
DriverInit {
scheme: Scheme,
reason: String,
},
#[error("object-store I/O error at '{path}': {source}")]
Io {
path: String,
#[source]
source: object_store::Error,
},
#[error("layout error at '{path}': {reason}")]
Layout {
path: String,
reason: String,
},
}
impl StorageError {
pub(crate) fn io(path: impl Into<String>, source: object_store::Error) -> Self {
Self::Io {
path: path.into(),
source,
}
}
pub(crate) fn layout(path: impl Into<String>, reason: impl Into<String>) -> Self {
Self::Layout {
path: path.into(),
reason: reason.into(),
}
}
}