1#[derive(Debug, thiserror::Error)]
2#[non_exhaustive]
3pub enum TokenError {
4 #[error("invalid token format")]
5 InvalidFormat,
6 #[error("verification failed: {0}")]
7 VerificationFailed(String),
8 #[error("{claim}: expected '{expected}', got '{actual}'")]
9 ClaimMismatch {
10 claim: &'static str,
11 expected: String,
12 actual: String,
13 },
14 #[error("missing claim: {0}")]
15 MissingClaim(&'static str),
16 #[error("missing payload")]
17 MissingPayload,
18 #[error("invalid footer")]
19 InvalidFooter,
20 #[error("missing footer")]
21 MissingFooter,
22 #[error("token expired")]
23 Expired,
24}
25
26#[derive(Debug, thiserror::Error)]
27#[non_exhaustive]
28pub enum Error {
29 #[error("OAuth2 {operation} failed (status={status:?}): {detail}")]
30 OAuth {
31 operation: &'static str,
32 status: Option<u16>,
33 detail: String,
34 },
35 #[cfg(feature = "oauth")]
36 #[error("HTTP error: {0}")]
37 Http(#[from] reqwest::Error),
38 #[error("token error: {0}")]
39 Token(#[from] TokenError),
40 #[error("sdk-core: {0}")]
47 SdkCore(#[from] ::ppoppo_sdk_core::SdkCoreError),
48 #[cfg(feature = "oauth")]
49 #[error("Invalid URL: {0}")]
50 InvalidUrl(#[from] url::ParseError),
51}
52
53#[cfg(test)]
54mod tests {
55 use super::*;
56 use static_assertions::assert_impl_all;
57
58 assert_impl_all!(Error: Send, Sync);
59 assert_impl_all!(TokenError: Send, Sync);
60}