Skip to main content

bsv_messagebox_client/
error.rs

1use thiserror::Error;
2
3/// Unified error type for all MessageBox client operations.
4///
5/// Uses String variants for wallet and auth errors to avoid tight coupling
6/// to SDK error internals — call sites use `.map_err(|e| MessageBoxError::Wallet(e.to_string()))`.
7#[derive(Error, Debug)]
8pub enum MessageBoxError {
9    #[error("wallet error: {0}")]
10    Wallet(String),
11    #[error("auth error: {0}")]
12    Auth(String),
13    #[error("HTTP error: status {0} from {1}")]
14    Http(u16, String),
15    #[error("encryption error: {0}")]
16    Encryption(String),
17    #[error("JSON parse error: {0}")]
18    Json(#[from] serde_json::Error),
19    #[error("missing header: {0}")]
20    MissingHeader(String),
21    #[error("not initialized")]
22    NotInitialized,
23    #[error("websocket error: {0}")]
24    WebSocket(String),
25    #[error("overlay error: {0}")]
26    Overlay(String),
27    #[error("validation error: {0}")]
28    Validation(String),
29}