atproto_oauth_axum/
errors.rs1use thiserror::Error;
17
18#[derive(Debug, Error)]
23pub enum OAuthCallbackError {
24 #[error("error-atproto-oauth-axum-callback-1 No OAuth request found for state")]
26 NoOAuthRequestFound,
27
28 #[error(
30 "error-atproto-oauth-axum-callback-2 Invalid issuer: expected {expected}, got {actual}"
31 )]
32 InvalidIssuer {
33 expected: String,
35 actual: String,
37 },
38
39 #[error("error-atproto-oauth-axum-callback-3 No DID document found for OAuth request")]
41 NoDIDDocumentFound,
42
43 #[error("error-atproto-oauth-axum-callback-4 No signing key found for OAuth request")]
45 NoSigningKeyFound,
46
47 #[error("error-atproto-oauth-axum-callback-5 Operation failed: {error}")]
49 OperationFailed {
50 error: anyhow::Error,
52 },
53
54 #[error("error-atproto-oauth-axum-callback-6 Key operation failed: {error}")]
56 KeyOperationFailed {
57 error: atproto_identity::errors::KeyError,
59 },
60
61 #[error("error-atproto-oauth-axum-callback-7 OAuth client operation failed: {error}")]
63 OAuthClientOperationFailed {
64 error: atproto_oauth::errors::OAuthClientError,
66 },
67}
68
69impl From<anyhow::Error> for OAuthCallbackError {
70 fn from(error: anyhow::Error) -> Self {
71 OAuthCallbackError::OperationFailed { error }
72 }
73}
74
75impl From<atproto_identity::errors::KeyError> for OAuthCallbackError {
76 fn from(error: atproto_identity::errors::KeyError) -> Self {
77 OAuthCallbackError::KeyOperationFailed { error }
78 }
79}
80
81impl From<atproto_oauth::errors::OAuthClientError> for OAuthCallbackError {
82 fn from(error: atproto_oauth::errors::OAuthClientError) -> Self {
83 OAuthCallbackError::OAuthClientOperationFailed { error }
84 }
85}
86
87#[derive(Debug, Error)]
92pub enum OAuthLoginError {
93 #[error("error-atproto-oauth-axum-login-1 Failed to resolve subject: {error}")]
95 SubjectResolutionFailed {
96 error: anyhow::Error,
98 },
99
100 #[error("error-atproto-oauth-axum-login-2 Failed to query PLC directory: {error}")]
102 PLCQueryFailed {
103 error: anyhow::Error,
105 },
106
107 #[error("error-atproto-oauth-axum-login-3 Failed to query web DID: {error}")]
109 WebDIDQueryFailed {
110 error: anyhow::Error,
112 },
113
114 #[error("error-atproto-oauth-axum-login-4 Unsupported DID method: {did}")]
116 UnsupportedDIDMethod {
117 did: String,
119 },
120
121 #[error("error-atproto-oauth-axum-login-5 No PDS endpoint found in DID document")]
123 NoPDSEndpointFound,
124
125 #[error("error-atproto-oauth-axum-login-6 Failed to get PDS resources: {error}")]
127 PDSResourcesFailed {
128 error: anyhow::Error,
130 },
131
132 #[error("error-atproto-oauth-axum-login-7 Failed to generate DPoP key: {error}")]
134 DPoPKeyGenerationFailed {
135 error: anyhow::Error,
137 },
138
139 #[error("error-atproto-oauth-axum-login-8 Invalid private signing key: {error}")]
141 InvalidPrivateSigningKey {
142 error: anyhow::Error,
144 },
145
146 #[error("error-atproto-oauth-axum-login-9 OAuth init failed: {error}")]
148 OAuthInitFailed {
149 error: anyhow::Error,
151 },
152
153 #[error("error-atproto-oauth-axum-login-10 Failed to derive public key: {error}")]
155 PublicKeyDerivationFailed {
156 error: anyhow::Error,
158 },
159
160 #[error("error-atproto-oauth-axum-login-11 Failed to store OAuth request: {error}")]
162 OAuthRequestStorageFailed {
163 error: anyhow::Error,
165 },
166}