ring_client/client/api/
error.rs

1use thiserror::Error;
2
3/// Errors which can occur when trying to communicate with the Ring API.
4///
5/// This may either be the REST API or the WebSocket API.
6#[derive(Error, Debug)]
7#[error(transparent)]
8#[non_exhaustive]
9pub enum ApiError {
10    /// When communicating with Ring over a REST API an error occurred.
11    #[error("An error occurred while trying to communicate with the Ring OAuth API")]
12    RequestError(#[from] reqwest::Error),
13
14    /// Decoding the response from a Ring endpoint failed.
15    #[error("An error occurred while decoding the response from the Ring API: {0}")]
16    InvalidResponse(#[from] serde_json::Error),
17
18    /// When communicating with Ring over a WebSocket connection an error occurred.
19    #[error("An error occurred while trying to communicate with the Ring API: {0}")]
20    WebsocketError(#[from] tokio_tungstenite::tungstenite::Error),
21
22    /// When refreshing the authentication tokens an error occurred.
23    #[error("An error occurred while trying to refresh the authentication tokens")]
24    AuthenticationRefreshFailed(crate::client::authentication::AuthenticationError),
25
26    /// An attempt to write to a closed WebSocket sink was made.
27    #[error("An error occurred while sending a message")]
28    SinkAlreadyClosed,
29}