| 1 | use thiserror::Error; |
| 2 | |
| 3 | #[derive(Debug, Error)] |
| 4 | pub enum Error { |
| 5 | #[error("failed to read the service account file {path}: {source}")] |
| 6 | ServiceAccountRead { |
| 7 | path: String, |
| 8 | #[source] |
| 9 | source: std::io::Error, |
| 10 | }, |
| 11 | |
| 12 | /// Deliberately carries no part of the file: a parse error could |
| 13 | /// otherwise quote key material. |
| 14 | #[error("the service account JSON is not valid or lacks client_email/private_key")] |
| 15 | ServiceAccountInvalid, |
| 16 | |
| 17 | #[error("failed to sign the service account JWT: {0}")] |
| 18 | Jwt(#[from] jsonwebtoken::errors::Error), |
| 19 | |
| 20 | #[error("http request failed: {0}")] |
| 21 | Http(#[from] reqwest::Error), |
| 22 | |
| 23 | #[error("failed to decode JSON response: {0}")] |
| 24 | Json(#[from] serde_json::Error), |
| 25 | |
| 26 | #[error("Google OAuth token exchange returned {status}: {detail}")] |
| 27 | Token { status: u16, detail: String }, |
| 28 | |
| 29 | #[error("Google Play API returned {status}: {detail}")] |
| 30 | Api { status: u16, detail: String }, |
| 31 | } |
| 32 | |
| 33 | pub type Result<T> = std::result::Result<T, Error>; |