Skip to main content

zvault_storage/
error.rs

1//! Storage error types.
2//!
3//! Every error variant carries enough context to diagnose the problem
4//! without a debugger, following `VaultRS` error handling standards.
5
6/// Errors that can occur during storage operations.
7#[derive(Debug, thiserror::Error)]
8pub enum StorageError {
9    /// Failed to open the storage backend at the given path.
10    #[error("failed to open storage at '{path}': {reason}")]
11    Open { path: String, reason: String },
12
13    /// Failed to read a value from storage.
14    #[error("failed to read key '{key}': {reason}")]
15    Read { key: String, reason: String },
16
17    /// Failed to write a value to storage.
18    #[error("failed to write key '{key}': {reason}")]
19    Write { key: String, reason: String },
20
21    /// Failed to delete a key from storage.
22    #[error("failed to delete key '{key}': {reason}")]
23    Delete { key: String, reason: String },
24
25    /// Failed to list keys with the given prefix.
26    #[error("failed to list keys with prefix '{prefix}': {reason}")]
27    List { prefix: String, reason: String },
28
29    /// A required column family or table was not found.
30    #[error("missing column family or table '{name}'")]
31    MissingTable { name: String },
32
33    /// Failed to begin or commit a transaction.
34    #[error("transaction failed: {reason}")]
35    Transaction { reason: String },
36
37    /// A storage key contained invalid UTF-8.
38    #[error("invalid key encoding: {reason}")]
39    InvalidKey { reason: String },
40}