1use linera_base::{
5 crypto::ValidatorPublicKey, data_types::NetworkDescription, identifiers::ChainId,
6};
7use linera_core::node::NodeError;
8use linera_persistent as persistent;
9use linera_version::VersionInfo;
10use thiserror_context::Context;
11
12#[cfg(feature = "benchmark")]
13use crate::benchmark::BenchmarkError;
14use crate::util;
15
16#[derive(Debug, thiserror::Error)]
17#[non_exhaustive]
18pub(crate) enum Inner {
19 #[error("BCS error: {0}")]
20 Bcs(#[from] bcs::Error),
21 #[error("chain error: {0}")]
22 Chain(#[from] linera_chain::ChainError),
23 #[error("chain client error: {0}")]
24 ChainClient(#[from] linera_core::client::ChainClientError),
25 #[error("options error: {0}")]
26 Options(#[from] crate::client_options::Error),
27 #[error("persistence error: {0}")]
28 Persistence(#[source] Box<dyn std::error::Error + Send + Sync>),
29 #[error("view error: {0}")]
30 View(#[from] linera_views::ViewError),
31 #[error("non-existent chain: {0:?}")]
32 NonexistentChain(linera_base::identifiers::ChainId),
33 #[error("no keypair found for chain: {0:?}")]
34 NonexistentKeypair(linera_base::identifiers::ChainId),
35 #[error("error on the local node: {0}")]
36 LocalNode(#[from] linera_core::local_node::LocalNodeError),
37 #[error("remote node operation failed: {0}")]
38 RemoteNode(#[from] linera_core::node::NodeError),
39 #[error("arithmetic error: {0}")]
40 Arithmetic(#[from] linera_base::data_types::ArithmeticError),
41 #[error("incorrect chain ownership")]
42 ChainOwnership,
43 #[cfg(feature = "benchmark")]
44 #[error("Benchmark error: {0}")]
45 Benchmark(#[from] BenchmarkError),
46 #[error("Validator version {remote} is not compatible with local version {local}.")]
47 UnexpectedVersionInfo {
48 remote: Box<VersionInfo>,
49 local: Box<VersionInfo>,
50 },
51 #[error("Failed to get version information for validator {address}: {error}")]
52 UnavailableVersionInfo {
53 address: String,
54 error: Box<NodeError>,
55 },
56 #[error("Validator's network description {remote:?} does not match our own: {local:?}.")]
57 UnexpectedNetworkDescription {
58 remote: Box<NetworkDescription>,
59 local: Box<NetworkDescription>,
60 },
61 #[error("Failed to get network description for validator {address}: {error}")]
62 UnavailableNetworkDescription {
63 address: String,
64 error: Box<NodeError>,
65 },
66 #[error("Signature for public key {public_key} is invalid.")]
67 InvalidSignature { public_key: ValidatorPublicKey },
68 #[error("Failed to get chain info for validator {address} and chain {chain_id}: {error}")]
69 UnavailableChainInfo {
70 address: String,
71 chain_id: ChainId,
72 error: Box<NodeError>,
73 },
74}
75
76thiserror_context::impl_context!(Error(Inner));
77
78util::impl_from_dynamic!(Inner:Persistence, persistent::memory::Error);
79#[cfg(feature = "fs")]
80util::impl_from_dynamic!(Inner:Persistence, persistent::file::Error);
81#[cfg(web)]
82util::impl_from_dynamic!(Inner:Persistence, persistent::indexed_db::Error);