Skip to main content

android_sms_gateway/
error.rs

1use thiserror::Error;
2
3/// Errors returned by the SMSGate client.
4#[derive(Error, Debug)]
5pub enum Error {
6    /// An unexpected client-side error occurred.
7    #[error("api error: client error: {0}")]
8    Client(String),
9
10    /// The server rejected the request due to invalid data.
11    #[error("api error: client error: validation failed: {0}")]
12    BadRequest(String),
13
14    /// The request conflicts with the current state (e.g., duplicate or conflicting fields).
15    #[error("api error: client error: conflict: {0}")]
16    Conflict(String),
17
18    /// The request requires authentication (HTTP 401).
19    #[error("api error: client error: unauthorized: {0}")]
20    Unauthorized(String),
21
22    /// The server refused the request due to insufficient permissions (HTTP 403).
23    #[error("api error: client error: forbidden: {0}")]
24    Forbidden(String),
25
26    /// The requested resource was not found (HTTP 404).
27    #[error("api error: client error: not found: {0}")]
28    NotFound(String),
29
30    /// The request was well-formed but semantically invalid (HTTP 422).
31    #[error("api error: client error: unprocessable entity: {0}")]
32    UnprocessableEntity(String),
33
34    /// Too many requests were made in a given amount of time (HTTP 429).
35    #[error("api error: client error: too many requests: {0}")]
36    TooManyRequests(String),
37
38    /// The server returned a 5xx error.
39    #[error("api error: server error: {0}")]
40    Server(String),
41
42    /// An HTTP transport error occurred (connection, timeout, etc.).
43    #[error("http error: {0}")]
44    Http(#[from] reqwest::Error),
45
46    /// The provided configuration is invalid.
47    #[error("invalid config: {0}")]
48    InvalidConfig(String),
49
50    /// A value failed client-side validation.
51    #[error("validation failed: {0}")]
52    Validation(String),
53
54    /// Two or more mutually exclusive fields were provided.
55    #[error("conflict fields: {0}")]
56    ConflictFields(String),
57
58    /// JSON serialization or deserialization failed.
59    #[error("json error: {0}")]
60    Json(#[from] serde_json::Error),
61}