elemental_core/auth/
error.rs1#[cfg(feature = "microsoft-auth")]
2pub type DeviceCodeRequestError = oauth2::RequestTokenError<
3 oauth2::HttpClientError<reqwest::Error>,
4 oauth2::basic::BasicErrorResponse,
5>;
6
7#[cfg(feature = "microsoft-auth")]
8pub type DeviceTokenRequestError = oauth2::RequestTokenError<
9 oauth2::HttpClientError<reqwest::Error>,
10 oauth2::DeviceCodeErrorResponse,
11>;
12
13#[cfg(feature = "microsoft-auth")]
14#[derive(Debug, thiserror::Error)]
15pub enum XuidDecodeError {
16 #[error("Minecraft access token is not a three-part JWT")]
17 MalformedToken,
18
19 #[error("decode Minecraft access token payload failed")]
20 Payload(#[from] base64::DecodeError),
21
22 #[error("parse Minecraft access token claims failed")]
23 Claims(#[from] serde_json::Error),
24}
25
26#[derive(Debug, thiserror::Error)]
27#[non_exhaustive]
28pub enum Error {
29 #[cfg(feature = "microsoft-auth")]
30 #[error("build HTTP client failed")]
31 HttpClientBuild {
32 #[source]
33 source: reqwest::Error,
34 },
35
36 #[cfg(feature = "microsoft-auth")]
37 #[error("parse {endpoint} endpoint failed")]
38 Endpoint {
39 endpoint: &'static str,
40 #[source]
41 source: oauth2::url::ParseError,
42 },
43
44 #[cfg(feature = "microsoft-auth")]
45 #[error("request device code failed")]
46 DeviceCodeRequest {
47 #[source]
48 source: DeviceCodeRequestError,
49 },
50
51 #[cfg(feature = "microsoft-auth")]
52 #[error("request device access token failed")]
53 DeviceTokenRequest {
54 #[source]
55 source: DeviceTokenRequestError,
56 },
57
58 #[cfg(feature = "microsoft-auth")]
59 #[error("refresh Microsoft access token failed")]
60 RefreshTokenRequest {
61 #[source]
62 source: DeviceCodeRequestError,
63 },
64
65 #[cfg(feature = "microsoft-auth")]
66 #[error("exchange Microsoft token for Minecraft token failed")]
67 MinecraftExchange {
68 #[source]
69 source: minecraft_msa_auth::MinecraftAuthorizationError<reqwest::Error>,
70 },
71
72 #[cfg(feature = "microsoft-auth")]
73 #[error("send Minecraft profile request failed")]
74 ProfileRequest {
75 #[source]
76 source: reqwest::Error,
77 },
78
79 #[cfg(feature = "microsoft-auth")]
80 #[error("Minecraft profile request returned an unsuccessful status")]
81 ProfileStatus {
82 #[source]
83 source: reqwest::Error,
84 },
85
86 #[cfg(feature = "microsoft-auth")]
87 #[error("Microsoft OAuth response contains no refresh token")]
88 MicrosoftRefreshTokenMissing,
89
90 #[cfg(feature = "microsoft-auth")]
91 #[error("decode XUID from Minecraft access token failed")]
92 XuidDecode {
93 #[source]
94 source: XuidDecodeError,
95 },
96
97 #[cfg(feature = "microsoft-auth")]
98 #[error("Minecraft access token contains no XUID")]
99 XuidMissing,
100
101 #[cfg(feature = "microsoft-auth")]
102 #[error("decode Minecraft profile response failed")]
103 ProfileDecode {
104 #[source]
105 source: reqwest::Error,
106 },
107
108 #[error("texture operation '{operation}' is not supported for this account")]
109 TextureUnsupported { operation: &'static str },
110
111 #[error(
112 "account type does not match provider '{expected_authorizer}' (found '{actual_authorizer}')"
113 )]
114 AccountTypeMismatch {
115 expected_authorizer: &'static str,
116 actual_authorizer: String,
117 },
118
119 #[cfg(feature = "microsoft-auth")]
120 #[error("send texture request for '{operation}' failed")]
121 TextureRequest {
122 operation: &'static str,
123 #[source]
124 source: reqwest::Error,
125 },
126
127 #[cfg(feature = "microsoft-auth")]
128 #[error("texture request for '{operation}' returned {status}: {body}")]
129 TextureStatus {
130 operation: &'static str,
131 status: reqwest::StatusCode,
132 body: String,
133 },
134
135 #[error("unknown skin model '{model}'")]
136 TextureModelUnknown { model: String },
137
138 #[cfg(feature = "microsoft-auth")]
139 #[error("verification handler failed")]
140 VerificationHandler {
141 #[source]
142 source: Box<dyn std::error::Error + Send + Sync>,
143 },
144
145 #[cfg(feature = "yggdrasil-auth")]
146 #[error("Yggdrasil request failed")]
147 Yggdrasil {
148 #[source]
149 source: nidhogg::error::NidhoggError,
150 },
151
152 #[cfg(feature = "yggdrasil-auth")]
153 #[error("Yggdrasil authentication response contains no Minecraft profile")]
154 YggdrasilProfileMissing,
155
156 #[cfg(feature = "yggdrasil-auth")]
157 #[error("Yggdrasil account has no base URL")]
158 YggdrasilBaseUrlMissing,
159
160 #[cfg(feature = "yggdrasil-auth")]
161 #[error("parse Yggdrasil profile textures failed")]
162 YggdrasilTexture {
163 #[source]
164 source: nidhogg::types::profile::ProfilePropertyError,
165 },
166}
167
168pub type Result<T> = std::result::Result<T, Error>;