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 //
31 // 3rd party errors
32 //
33 /// An HTTP client error occurred.
34 ///
35 /// This wraps errors from the `reqwest` HTTP client library,
36 /// such as network connectivity issues or timeout errors.
37 #[error(transparent)]
38 HttpError(#[from] reqwest::Error),
39
40 /// Failed to serialize or deserialize JSON data.
41 ///
42 /// This typically indicates an unexpected API response format.
43 #[error(transparent)]
44 Serialization(#[from] serde_json::Error),
45}