linera_views/
error.rs

1// Copyright (c) Zefchain Labs, Inc.
2// SPDX-License-Identifier: Apache-2.0
3
4/// Main error type for the crate.
5#[derive(thiserror::Error, Debug)]
6pub enum ViewError {
7    /// BCS serialization error.
8    #[error(transparent)]
9    BcsError(#[from] bcs::Error),
10
11    /// We failed to acquire an entry in a `CollectionView`.
12    #[error("trying to access a collection view while some entries are still being accessed")]
13    CannotAcquireCollectionEntry,
14
15    /// Input output error.
16    #[error("I/O error")]
17    IoError(#[from] std::io::Error),
18
19    /// Arithmetic error
20    #[error(transparent)]
21    ArithmeticError(#[from] linera_base::data_types::ArithmeticError),
22
23    /// Failed to lock a reentrant collection entry since it is currently being accessed
24    #[error(
25        "failed to lock a reentrant collection entry since it is currently being accessed: {0:?}"
26    )]
27    TryLockError(Vec<u8>),
28
29    /// Tokio errors can happen while joining.
30    #[error("panic in sub-task: {0}")]
31    TokioJoinError(#[from] tokio::task::JoinError),
32
33    /// Errors within the context can occur and are presented as `ViewError`.
34    #[error("storage operation error in {backend}: {error}")]
35    StoreError {
36        /// The name of the backend that produced the error
37        backend: &'static str,
38        /// The inner error
39        #[source]
40        error: Box<dyn std::error::Error + Send + Sync>,
41    },
42
43    /// The key must not be too long
44    #[error("the key must not be too long")]
45    KeyTooLong,
46
47    /// The entry does not exist in memory
48    // FIXME(#148): This belongs to a future `linera_storage::StoreError`.
49    #[error("entry does not exist in storage: {0}")]
50    NotFound(String),
51
52    /// The database is corrupt: Entries don't have the expected hash.
53    #[error("inconsistent database entries")]
54    InconsistentEntries,
55
56    /// The database is corrupt: Some entries are missing
57    #[error("missing database entries")]
58    MissingEntries,
59
60    /// The values are incoherent.
61    #[error("post load values error")]
62    PostLoadValuesError,
63}