Skip to main content

doido_storage/
error.rs

1//! Typed storage errors (`thiserror` per crate, per the framework convention).
2//!
3//! Public APIs return `doido_core::Result<T>` (anyhow) like the rest of the
4//! framework; [`StorageError`] gives callers a matchable error type and converts
5//! into `anyhow::Error` automatically via the `?` operator.
6
7/// Errors raised by the storage layer.
8#[derive(Debug, thiserror::Error)]
9pub enum StorageError {
10    /// A blob/attachment/object was not found.
11    #[error("storage: not found: {0}")]
12    NotFound(String),
13
14    /// A filesystem or backend I/O failure.
15    #[error("storage: io error: {0}")]
16    Io(String),
17
18    /// The selected service backend failed (S3/Azure/disk).
19    #[error("storage: backend error: {0}")]
20    Backend(String),
21
22    /// The `storage` configuration is invalid or selects an unavailable backend.
23    #[error("storage: config error: {0}")]
24    Config(String),
25
26    /// A signed id / signed URL is malformed, tampered with, or expired.
27    #[error("storage: invalid signature: {0}")]
28    InvalidSignature(String),
29
30    /// A database (metadata) failure.
31    #[error("storage: database error: {0}")]
32    Db(String),
33}
34
35impl From<std::io::Error> for StorageError {
36    fn from(e: std::io::Error) -> Self {
37        StorageError::Io(e.to_string())
38    }
39}