use thiserror::Error;
#[derive(Debug, Error)]
pub enum ElectrumError {
#[error("Connection failed: {0}")]
ConnectionFailed(String),
#[error("Connection timeout")]
Timeout,
#[error("Server error ({code}): {message}")]
ServerError {
code: i32,
message: String,
},
#[error("Invalid address: {0}")]
InvalidAddress(String),
#[error("Invalid response: {0}")]
InvalidResponse(String),
#[error("TLS error: {0}")]
TlsError(String),
#[error("I/O error: {0}")]
IoError(#[from] std::io::Error),
#[error("JSON error: {0}")]
JsonError(#[from] serde_json::Error),
#[error("Request ID mismatch: expected {expected}, got {got}")]
IdMismatch {
expected: u64,
got: u64,
},
#[error("Server disconnected")]
Disconnected,
#[error("Invalid scripthash: {0}")]
InvalidScripthash(String),
#[error("Certificate pinning failed: {0}")]
CertificatePinningFailed(String),
#[error("No servers available")]
NoServersAvailable,
#[error("Connection pool exhausted")]
PoolExhausted,
#[error("Subscription error: {0}")]
SubscriptionError(String),
}
pub type Result<T> = std::result::Result<T, ElectrumError>;