Skip to main content

rointe_core/
error.rs

1use thiserror::Error;
2
3/// All errors that can be returned by `rointe-core`.
4///
5/// This enum is `#[non_exhaustive]` — new variants may be added in future
6/// minor versions without a breaking change.
7#[derive(Debug, Error)]
8#[non_exhaustive]
9pub enum RointeError {
10    /// Authentication failed (bad credentials, expired token, etc.).
11    #[error("Authentication error: {0}")]
12    Auth(String),
13
14    /// An underlying HTTP transport error from `reqwest`.
15    #[error("Network error: {0}")]
16    Network(#[from] reqwest::Error),
17
18    /// The Firebase Realtime Database returned an unexpected response or
19    /// the response could not be parsed as the expected schema.
20    #[error("Firebase error: {0}")]
21    Firebase(String),
22
23    /// A device ID was referenced that does not exist in the installation.
24    #[error("Device not found: {0}")]
25    DeviceNotFound(String),
26
27    /// JSON serialisation or deserialisation failed.
28    #[error("JSON error: {0}")]
29    Json(#[from] serde_json::Error),
30}
31
32/// Convenience `Result` alias for `rointe-core` operations.
33pub type Result<T> = std::result::Result<T, RointeError>;