use thiserror::Error;
#[derive(Debug, Error)]
#[non_exhaustive]
pub enum ObjStoreError {
#[error("object store error: {0}")]
Store(#[from] object_store::Error),
#[error("archive {object}: expected {expected} bytes, found {}", .found.map_or_else(|| "no object".to_string(), |n| n.to_string()))]
IntegrityCheckFailed {
object: String,
expected: usize,
found: Option<usize>,
},
#[error("cache I/O error: {0}")]
CacheIo(#[source] std::io::Error),
#[error("object not found: {path}")]
NotFound {
path: String,
},
#[error("invalid configuration: {detail}")]
InvalidConfig {
detail: String,
},
#[error("invalid URL: {0}")]
InvalidUrl(#[from] url::ParseError),
#[error("storage error: {0}")]
Storage(#[from] crate::storage::StorageError),
#[error("segment error: {0}")]
Segment(#[source] crate::segment::SegmentError),
#[error("parquet error: {0}")]
Parquet(String),
#[error("I/O error: {0}")]
Io(#[source] std::io::Error),
}
pub type Result<T> = std::result::Result<T, ObjStoreError>;
impl From<ObjStoreError> for crate::storage::StorageError {
fn from(e: ObjStoreError) -> Self {
match e {
ObjStoreError::NotFound { path } => crate::storage::StorageError::NotFound {
path: std::path::PathBuf::from(path),
},
other => crate::storage::StorageError::InvalidPath {
detail: other.to_string(),
},
}
}
}