aurelin_framework/storage/
error.rs1use std::error::Error;
2
3use object_store::Error as ObjectStoreError;
4
5pub type StorageResult<T> = Result<T, StorageError>;
7
8#[derive(Debug, thiserror::Error)]
10pub enum StorageError {
11 #[error("invalid storage path '{path}': {reason}")]
13 InvalidPath { path: String, reason: String },
14
15 #[error("object '{path}' was not found")]
17 NotFound { path: String },
18
19 #[error("disk does not support {capability}")]
21 UnsupportedCapability { capability: &'static str },
22
23 #[error("input stream failed: {0}")]
25 InputStream(#[source] Box<dyn Error + Send + Sync>),
26
27 #[error("storage backend failed: {0}")]
29 Backend(#[source] ObjectStoreError),
30
31 #[error("local disk setup failed: {0}")]
33 LocalSetup(#[source] ObjectStoreError),
34}
35
36impl StorageError {
37 pub(crate) fn backend(error: ObjectStoreError, path: &str) -> Self {
38 match error {
39 ObjectStoreError::NotFound { .. } => Self::NotFound { path: path.to_owned() },
40 error => Self::Backend(error),
41 }
42 }
43
44 pub(crate) fn input(error: impl Error + Send + Sync + 'static) -> Self {
45 Self::InputStream(Box::new(error))
46 }
47}