ring_client/client/authentication/error.rs
1use thiserror::Error;
2
3/// Errors which can occur when trying to authenticate with the Ring API.
4#[derive(Error, Debug)]
5#[error(transparent)]
6#[non_exhaustive]
7pub enum AuthenticationError {
8 /// The credentials provided were invalid.
9 #[error("The credentials provided were invalid")]
10 InvalidCredentials,
11
12 /// Ring presented a MFA (Two Factor Authentication) challenge which require
13 /// an SMS code to be sent to the user, and provided to the API.
14 ///
15 /// This typically occurs when logging in with a username and password
16 /// ([`crate::authentication::Credentials::User`]).
17 ///
18 /// You can use [`respond_to_challenge`](crate::client::Client::respond_to_challenge) to
19 /// continue the authentication process once the SMS code has been captured.
20 #[error("An MFA code is required to complete the authentication process")]
21 MfaCodeRequired,
22
23 /// An error occured with the Ring OAuth endpoint.
24 #[error("An error occurred while trying to communicate with the Ring OAuth API")]
25 OAuthError(#[from] reqwest::Error),
26
27 /// The response from the Ring OAuth API could not be decoded.
28 #[error("An error occurred while decoding the response from the Ring OAuth API: {0}")]
29 InvalidResponse(#[from] serde_json::Error),
30
31 /// Ring presented a challenge which was not expected, and is currently not supported
32 /// by the crate.
33 #[error("The presented challenge is not supported. Challenge was: {0}")]
34 UnsupportedChallenge(String),
35
36 /// Setting the session details with Ring failed.
37 #[error("An error occurred while trying to set the session details with Ring")]
38 SessionFailed,
39}