smplx_sdk/provider/error.rs
1use crate::provider::rpc::error::RpcError;
2
3/// Defines standard errors possible when using a blockchain interaction provider.
4#[derive(Debug, thiserror::Error)]
5pub enum ProviderError {
6 /// Wrapper around an RPC-level error representing transport or network-level connectivity failures to the inner node.
7 #[error(transparent)]
8 Rpc(#[from] RpcError),
9
10 /// Error indicating that a standard HTTP request to a provider (such as an Esplora REST instance) encountered a failure.
11 #[error("HTTP request failed: {0}")]
12 Request(String),
13
14 /// Error indicating the configured timeout to wait for transaction confirmation elapsed without confirmation.
15 #[error("Couldn't wait for the transaction to be confirmed")]
16 Confirmation(),
17
18 /// Error indicating a provider returned a non-success response explicitly rejecting a broadcasted transaction payload.
19 #[error("Broadcast failed with HTTP {status} for {url}: {message}")]
20 BroadcastRejected {
21 /// The HTTP status code indicating the failure.
22 status: u16,
23 /// The URL that the broadcast was sent to.
24 url: String,
25 /// The error message returned by the provider.
26 message: String,
27 },
28
29 /// Error indicating that a provider's raw response body was unable to be correctly deserialized into native structs or types.
30 #[error("Failed to deserialize response: {0}")]
31 Deserialize(String),
32
33 /// Error indicating an incorrectly formatted transaction ID string was encountered.
34 #[error("Invalid txid format: {0}")]
35 InvalidTxid(String),
36}