atproto_oauth_aip/errors.rs
1//! # Structured Error Types for OAuth AIP Workflow
2//!
3//! Comprehensive error handling for AT Protocol OAuth AIP (Identity Provider) workflow operations
4//! using structured error types with the `thiserror` library. All errors follow the project
5//! convention of prefixed error codes with descriptive messages.
6//!
7//! ## Error Categories
8//!
9//! - **`OAuthWorkflowError`** (workflow-1 to workflow-8): OAuth workflow operations including PAR, token exchange, and session management
10//!
11//! ## Error Format
12//!
13//! All errors use the standardized format: `error-atproto-oauth-aip-{domain}-{number} {message}: {details}`
14
15use thiserror::Error;
16
17/// Errors that can occur during OAuth workflow operations.
18///
19/// These errors represent failures in the complete OAuth authentication flow
20/// for AT Protocol Identity Provider integration, including authorization
21/// request initiation, token exchange, and session establishment.
22#[derive(Debug, Error)]
23pub enum OAuthWorkflowError {
24 /// Failed to send PAR HTTP request.
25 #[error("error-atproto-oauth-aip-workflow-1 PAR HTTP request failed: {0}")]
26 ParRequestFailed(#[source] reqwest::Error),
27
28 /// Failed to parse PAR response JSON.
29 #[error("error-atproto-oauth-aip-workflow-2 PAR HTTP request parse failed: {0}")]
30 ParResponseParseFailed(#[source] reqwest::Error),
31
32 /// PAR response contained an error.
33 #[error("error-atproto-oauth-aip-workflow-3 PAR HTTP response invalid: {message}")]
34 ParResponseInvalid {
35 /// Error message from the PAR response.
36 message: String,
37 },
38
39 /// Failed to send token exchange HTTP request.
40 #[error("error-atproto-oauth-aip-workflow-4 Token request failed: {0}")]
41 TokenRequestFailed(#[source] reqwest::Error),
42
43 /// Failed to parse token response JSON.
44 #[error("error-atproto-oauth-aip-workflow-5 Token response json parsing failed: {0}")]
45 TokenResponseParseFailed(#[source] reqwest::Error),
46
47 /// Failed to send session exchange HTTP request.
48 #[error("error-atproto-oauth-aip-workflow-6 Session request failed: {0}")]
49 SessionRequestFailed(#[source] reqwest::Error),
50
51 /// Failed to parse session response JSON.
52 #[error("error-atproto-oauth-aip-workflow-7 Session json parsing failed: {0}")]
53 SessionResponseParseFailed(#[source] reqwest::Error),
54
55 /// Session response contained an error.
56 #[error("error-atproto-oauth-aip-workflow-8 Session response invalid: {message}")]
57 SessionResponseInvalid {
58 /// Error message from the session response.
59 message: String,
60 },
61}