ffrelay_api/error.rs
1//! Error types for the Firefox Relay API client.
2
3use thiserror::Error;
4
5/// A specialized `Result` type for Firefox Relay API operations.
6pub type Result<T> = core::result::Result<T, Error>;
7
8/// Errors that can occur when interacting with the Firefox Relay API.
9#[derive(Debug, Error)]
10pub enum Error {
11 /// HTTP request failed with the given status code.
12 ///
13 /// This typically indicates a server error or invalid request.
14 #[error("Http Error {http_status}")]
15 RequestFailure { http_status: u16 },
16
17 /// The specified relay ID was not found in your account.
18 ///
19 /// This occurs when trying to delete or access a relay that doesn't exist
20 /// or doesn't belong to your account.
21 #[error("Email Id not found")]
22 RelayIdNotFound,
23
24 /// Failed to delete the email relay.
25 ///
26 /// The server rejected the deletion request. Check the status code for details.
27 #[error("Deletion Failure. Status code: {http_status}")]
28 EmailDeletionFailure { http_status: u16 },
29
30 /// Failed to update the email relay.
31 ///
32 /// The server rejected the deletion request. Check the status code for details.
33 #[error("Update Failure. Status code: {http_status}")]
34 EmailUpdateFailure { http_status: u16 },
35
36 //
37 // 3rd party errors
38 //
39 /// An HTTP client error occurred.
40 ///
41 /// This wraps errors from the `reqwest` HTTP client library,
42 /// such as network connectivity issues or timeout errors.
43 #[error(transparent)]
44 HttpError(#[from] reqwest::Error),
45
46 /// Failed to serialize or deserialize JSON data.
47 ///
48 /// This typically indicates an unexpected API response format.
49 #[error(transparent)]
50 Serialization(#[from] serde_json::Error),
51}