1use linera_base::{
5 crypto::ValidatorPublicKey, data_types::NetworkDescription, identifiers::ChainId,
6};
7use linera_core::node::NodeError;
8use linera_version::VersionInfo;
9
10#[cfg(not(web))]
11use crate::benchmark::BenchmarkError;
12use crate::util;
13
14#[derive(Debug, thiserror::Error)]
16#[non_exhaustive]
17pub enum Error {
18 #[error("I/O error: {0}")]
20 Io(#[from] std::io::Error),
21 #[error("BCS error: {0}")]
23 Bcs(#[from] bcs::Error),
24 #[error("chain error: {0}")]
26 Chain(#[from] linera_chain::ChainError),
27 #[error("chain client error: {0}")]
29 ChainClient(#[from] linera_core::client::chain_client::Error),
30 #[error("options error: {0}")]
32 Options(#[from] crate::client_options::Error),
33 #[error("wallet error: {0}")]
35 Wallet(#[source] Box<dyn std::error::Error + Send + Sync>),
36 #[error("view error: {0}")]
38 View(#[from] linera_views::ViewError),
39 #[error("error on the local node: {0}")]
41 LocalNode(#[from] linera_core::LocalNodeError),
42 #[error("remote node operation failed: {0}")]
44 RemoteNode(#[from] linera_core::node::NodeError),
45 #[error("arithmetic error: {0}")]
47 Arithmetic(#[from] linera_base::data_types::ArithmeticError),
48 #[error("incorrect chain ownership")]
50 ChainOwnership,
51 #[cfg(not(web))]
53 #[error("Benchmark error: {0}")]
54 Benchmark(#[from] BenchmarkError),
55 #[error("failed to assign the new chain to the wallet: {0}")]
57 AssignChain(#[source] Box<dyn std::error::Error + Send + Sync>),
58 #[error("failed to change chain ownership: {0}")]
60 ChangeOwnership(#[source] Box<linera_core::client::chain_client::Error>),
61 #[error("failed to publish the module: {0}")]
63 PublishModule(#[source] Box<linera_core::client::chain_client::Error>),
64 #[error("failed to publish the data blob: {0}")]
66 PublishDataBlob(#[source] Box<linera_core::client::chain_client::Error>),
67 #[error("failed to read back the data blob: {0}")]
69 VerifyDataBlob(#[source] Box<linera_core::client::chain_client::Error>),
70 #[error("failed to deliver the outgoing messages that create the new chains: {0}")]
72 DeliverNewChainMessages(#[source] Box<linera_core::client::chain_client::Error>),
73 #[error("Validator version {remote} is not compatible with local version {local}.")]
75 UnexpectedVersionInfo {
76 remote: Box<VersionInfo>,
78 local: Box<VersionInfo>,
80 },
81 #[error("Failed to get version information for validator {address}: {error}")]
83 UnavailableVersionInfo {
84 address: String,
86 error: Box<NodeError>,
88 },
89 #[error("Validator's network description {remote:?} does not match our own: {local:?}.")]
91 UnexpectedNetworkDescription {
92 remote: Box<NetworkDescription>,
94 local: Box<NetworkDescription>,
96 },
97 #[error("Failed to get network description for validator {address}: {error}")]
99 UnavailableNetworkDescription {
100 address: String,
102 error: Box<NodeError>,
104 },
105 #[error("Signature for public key {public_key} is invalid.")]
107 InvalidSignature {
108 public_key: ValidatorPublicKey,
110 },
111 #[error("Failed to get chain info for validator {address} and chain {chain_id}: {error}")]
113 UnavailableChainInfo {
114 address: String,
116 chain_id: ChainId,
118 error: Box<NodeError>,
120 },
121}
122
123impl Error {
124 pub fn wallet(error: impl std::error::Error + Send + Sync + 'static) -> Self {
126 Self::Wallet(Box::new(error) as _)
127 }
128}
129
130util::impl_from_infallible!(Error);