Skip to main content

awaken_runtime_contract/contract/storage/
error.rs

1use thiserror::Error;
2
3/// Errors returned by storage operations.
4#[derive(Debug, Error)]
5pub enum StorageError {
6    /// The provided input violates a storage-level invariant.
7    #[error("validation error: {0}")]
8    Validation(String),
9    /// The requested entity was not found.
10    #[error("not found: {0}")]
11    NotFound(String),
12    /// An entity with the given key already exists.
13    #[error("already exists: {0}")]
14    AlreadyExists(String),
15    /// Optimistic concurrency conflict.
16    #[error("version conflict: expected {expected}, actual {actual}")]
17    VersionConflict {
18        /// The version the caller expected.
19        expected: u64,
20        /// The actual current version.
21        actual: u64,
22    },
23    /// Pending freeze selected a different set of pending ids than the caller
24    /// prepared against.
25    #[error("pending selection conflict: expected {expected_ids:?}, actual {actual_ids:?}")]
26    PendingSelectionConflict {
27        /// Pending ids selected by the caller before attempting freeze.
28        expected_ids: Vec<String>,
29        /// Pending ids selected inside the backend transaction.
30        actual_ids: Vec<String>,
31    },
32    /// An I/O error occurred.
33    #[error("io error: {0}")]
34    Io(String),
35    /// The operation may have committed durably, but the caller cannot know
36    /// whether follow-up promotion/cache work completed.
37    #[error("commit outcome unknown: {0}")]
38    CommitUnknown(String),
39    /// A serialization or deserialization error occurred.
40    #[error("serialization error: {0}")]
41    Serialization(String),
42}