| 1 | use thiserror::Error; |
| 2 | |
| 3 | #[derive(Debug, Error)] |
| 4 | pub enum Error { |
| 5 | #[error("failed to read private key at {path}: {source}")] |
| 6 | PrivateKeyRead { |
| 7 | path: String, |
| 8 | #[source] |
| 9 | source: std::io::Error, |
| 10 | }, |
| 11 | |
| 12 | #[error("failed to sign JWT: {0}")] |
| 13 | Jwt(#[from] jsonwebtoken::errors::Error), |
| 14 | |
| 15 | #[error("http request failed: {0}")] |
| 16 | Http(#[from] reqwest::Error), |
| 17 | |
| 18 | #[error("failed to decode JSON response: {0}")] |
| 19 | Json(#[from] serde_json::Error), |
| 20 | |
| 21 | #[error("App Store Connect API returned {status}: {detail}")] |
| 22 | Api { status: u16, detail: String }, |
| 23 | |
| 24 | #[error("failed to generate an RSA key pair: {0}")] |
| 25 | KeyGeneration(String), |
| 26 | |
| 27 | #[error("failed to build the certificate signing request: {0}")] |
| 28 | CsrGeneration(String), |
| 29 | } |
| 30 | |
| 31 | pub type Result<T> = std::result::Result<T, Error>; |