Skip to main content

pyra_privy/
error.rs

1/// Privy client errors.
2#[derive(Debug, thiserror::Error)]
3pub enum PrivyError {
4    /// Invalid configuration (bad key format, missing prefix, etc.).
5    #[error("Privy config error: {0}")]
6    Config(String),
7    /// HTTP request failed.
8    #[error("Privy HTTP error: {0}")]
9    Http(#[from] reqwest::Error),
10    /// Privy API returned an error response.
11    #[error("Privy API error ({status}): {body}")]
12    Api { status: u16, body: String },
13    /// JSON serialization/deserialization failed.
14    #[error("Privy serialization error: {0}")]
15    Serialization(String),
16}
17
18impl From<serde_json::Error> for PrivyError {
19    fn from(e: serde_json::Error) -> Self {
20        Self::Serialization(e.to_string())
21    }
22}
23
24pub type PrivyResult<T> = Result<T, PrivyError>;