wechat_api_rs/
error.rs

1use thiserror::Error;
2
3/// WeChat SDK error types
4#[derive(Error, Debug)]
5pub enum WeChatError {
6    #[error("HTTP request failed: {0}")]
7    Http(String),
8
9    #[error("Reqwest error: {0}")]
10    Reqwest(#[from] reqwest::Error),
11
12    #[error("JSON serialization/deserialization failed: {0}")]
13    Json(#[from] serde_json::Error),
14
15    #[error("WeChat API error: {code} - {message}")]
16    Api { code: i32, message: String },
17
18    #[error("Invalid configuration: {0}")]
19    Config(String),
20
21    #[error("Authentication failed: {0}")]
22    Auth(String),
23
24    #[error("Signature verification failed")]
25    Signature,
26
27    #[error("Encryption/Decryption failed: {0}")]
28    Crypto(String),
29
30    #[error("Invalid parameter: {0}")]
31    InvalidParam(String),
32
33    #[error("Other error: {0}")]
34    Other(String),
35}
36
37/// Result type alias for WeChat SDK
38pub type Result<T> = std::result::Result<T, WeChatError>;