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    /// Input output error.
12    #[error("I/O error")]
13    IoError(#[from] std::io::Error),
14
15    /// Arithmetic error
16    #[error(transparent)]
17    ArithmeticError(#[from] linera_base::data_types::ArithmeticError),
18
19    /// Failed to lock a reentrant collection entry since it is currently being accessed
20    #[error(
21        "failed to lock a reentrant collection entry since it is currently being accessed: {0:?}"
22    )]
23    TryLockError(Vec<u8>),
24
25    /// Tokio errors can happen while joining.
26    #[error("panic in sub-task: {0}")]
27    TokioJoinError(#[from] tokio::task::JoinError),
28
29    /// Errors within the context can occur and are presented as `ViewError`.
30    #[error("storage operation error in {backend}: {error}")]
31    StoreError {
32        /// The name of the backend that produced the error
33        backend: &'static str,
34        /// The inner error
35        #[source]
36        error: Box<dyn std::error::Error + Send + Sync>,
37    },
38
39    /// The key must not be too long
40    #[error("the key must not be too long")]
41    KeyTooLong,
42
43    /// The entry does not exist in memory
44    // FIXME(#148): This belongs to a future `linera_storage::StoreError`.
45    #[error("entry does not exist in storage: {0}")]
46    NotFound(String),
47
48    /// The database is corrupt: Entries don't have the expected hash.
49    #[error("inconsistent database entries")]
50    InconsistentEntries,
51
52    /// The database is corrupt: Some entries are missing
53    #[error("missing database entries")]
54    MissingEntries,
55
56    /// The values are incoherent.
57    #[error("post load values error")]
58    PostLoadValuesError,
59}