Skip to main content

blueprint_client_tangle/
error.rs

1//! Error types for the Tangle EVM client
2
3extern crate alloc;
4
5use alloc::string::{String, ToString};
6use alloy_primitives::Address;
7use thiserror::Error;
8
9/// Result type alias for Tangle EVM operations
10pub type Result<T> = core::result::Result<T, Error>;
11
12/// Errors that can occur when interacting with Tangle EVM contracts
13#[derive(Debug, Error)]
14pub enum Error {
15    /// Transport/RPC error from Alloy
16    #[error("Transport error: {0}")]
17    Transport(#[from] alloy_transport::TransportError),
18
19    /// Pending transaction error
20    #[error("Transaction error: {0}")]
21    PendingTransaction(#[from] alloy_provider::PendingTransactionError),
22
23    /// Contract call error
24    #[error("Contract error: {0}")]
25    Contract(String),
26
27    /// Configuration error
28    #[error("Configuration error: {0}")]
29    Config(String),
30
31    /// Keystore error
32    #[error("Keystore error: {0}")]
33    Keystore(#[from] blueprint_keystore::Error),
34
35    /// Blueprint not found
36    #[error("Blueprint {0} not found")]
37    BlueprintNotFound(u64),
38
39    /// Service not found
40    #[error("Service {0} not found")]
41    ServiceNotFound(u64),
42
43    /// Operator not found
44    #[error("Operator {0} not found")]
45    OperatorNotFound(Address),
46
47    /// Operator not registered for blueprint
48    #[error("Operator {0} not registered for blueprint {1}")]
49    OperatorNotRegistered(Address, u64),
50
51    /// Missing ECDSA key for operator
52    #[error("Missing ECDSA key for operator {0}")]
53    MissingEcdsa(Address),
54
55    /// Not configured for Tangle EVM
56    #[error("Not configured for Tangle EVM")]
57    NotTangle,
58
59    /// Party not found in operators list
60    #[error("Current party not found in operators list")]
61    PartyNotFound,
62
63    /// Missing status registry configuration
64    #[error("Status registry contract address not configured")]
65    MissingStatusRegistry,
66
67    /// Invalid address format
68    #[error("Invalid address: {0}")]
69    InvalidAddress(String),
70
71    /// Serde/serialization error
72    #[error("Serialization error: {0}")]
73    Serialization(String),
74
75    /// Provider not initialized
76    #[error("Provider not initialized - call connect() first")]
77    ProviderNotInitialized,
78
79    /// Client core error
80    #[error("Client error: {0}")]
81    ClientCore(#[from] blueprint_client_core::error::Error),
82
83    /// Generic error
84    #[error("{0}")]
85    Other(String),
86}
87
88impl From<serde_json::Error> for Error {
89    fn from(err: serde_json::Error) -> Self {
90        Error::Serialization(err.to_string())
91    }
92}