warp_wireguard_gen/error.rs
1//! Error types for the warp-wireguard-gen crate.
2
3use thiserror::Error;
4
5/// Result type alias for this crate.
6pub type Result<T> = std::result::Result<T, Error>;
7
8/// Errors that can occur when interacting with the Cloudflare WARP API.
9#[derive(Debug, Error)]
10pub enum Error {
11 /// HTTP request failed.
12 #[error("HTTP request failed: {0}")]
13 Http(#[from] reqwest::Error),
14
15 /// API returned an error response.
16 #[error("API error: {message} (code: {code})")]
17 Api {
18 /// Error code from the API.
19 code: i32,
20 /// Error message from the API.
21 message: String,
22 },
23
24 /// API response was invalid or missing expected fields.
25 #[error("Invalid API response: {0}")]
26 InvalidResponse(String),
27
28 /// Failed to parse endpoint address.
29 #[error("Failed to parse endpoint: {0}")]
30 InvalidEndpoint(String),
31
32 /// Failed to parse IP address.
33 #[error("Failed to parse IP address: {0}")]
34 InvalidAddress(String),
35
36 /// Invalid base64-encoded key.
37 #[error("Invalid base64 key: {0}")]
38 InvalidKey(String),
39
40 /// TLS configuration error.
41 #[error("TLS configuration error: {0}")]
42 Tls(String),
43
44 /// DNS resolution failed.
45 #[error("DNS resolution failed: {0}")]
46 DnsResolution(String),
47
48 /// Teams enrollment JWT token is invalid or expired.
49 ///
50 /// The JWT token obtained from the Cloudflare Access portal is ephemeral
51 /// and expires shortly after being issued. Re-authenticate and obtain
52 /// a fresh token.
53 #[error("Teams enrollment failed: {0}")]
54 TeamsEnrollment(String),
55}