Skip to main content

smplx_sdk_test/provider/
error.rs

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