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