elemental_core/auth/
error.rs1pub type DeviceCodeRequestError = oauth2::RequestTokenError<
2 oauth2::HttpClientError<reqwest::Error>,
3 oauth2::basic::BasicErrorResponse,
4>;
5
6pub type DeviceTokenRequestError = oauth2::RequestTokenError<
7 oauth2::HttpClientError<reqwest::Error>,
8 oauth2::DeviceCodeErrorResponse,
9>;
10
11#[derive(Debug, thiserror::Error)]
12#[non_exhaustive]
13pub enum Error {
14 #[error("build HTTP client failed")]
15 HttpClientBuild {
16 #[source]
17 source: reqwest::Error,
18 },
19
20 #[error("parse {endpoint} endpoint failed")]
21 Endpoint {
22 endpoint: &'static str,
23 #[source]
24 source: oauth2::url::ParseError,
25 },
26
27 #[error("request device code failed")]
28 DeviceCodeRequest {
29 #[source]
30 source: DeviceCodeRequestError,
31 },
32
33 #[error("request device access token failed")]
34 DeviceTokenRequest {
35 #[source]
36 source: DeviceTokenRequestError,
37 },
38
39 #[error("refresh Microsoft access token failed")]
40 RefreshTokenRequest {
41 #[source]
42 source: DeviceCodeRequestError,
43 },
44
45 #[error("exchange Microsoft token for Minecraft token failed")]
46 MinecraftExchange {
47 #[source]
48 source: minecraft_msa_auth::MinecraftAuthorizationError<reqwest::Error>,
49 },
50
51 #[error("send Minecraft profile request failed")]
52 ProfileRequest {
53 #[source]
54 source: reqwest::Error,
55 },
56
57 #[error("Minecraft profile request returned an unsuccessful status")]
58 ProfileStatus {
59 #[source]
60 source: reqwest::Error,
61 },
62
63 #[error("Microsoft OAuth response contains no refresh token")]
64 MicrosoftRefreshTokenMissing,
65
66 #[error("request Xbox XUID failed")]
67 XuidRequest {
68 #[source]
69 source: reqwest::Error,
70 },
71
72 #[error("decode Xbox XUID response failed")]
73 XuidDecode {
74 #[source]
75 source: reqwest::Error,
76 },
77
78 #[error("Xbox XUID response contains no XUID")]
79 XuidMissing,
80
81 #[error("decode Minecraft profile response failed")]
82 ProfileDecode {
83 #[source]
84 source: reqwest::Error,
85 },
86
87 #[error("texture operation '{operation}' is not supported for this account")]
88 TextureUnsupported { operation: &'static str },
89
90 #[error("send texture request for '{operation}' failed")]
91 TextureRequest {
92 operation: &'static str,
93 #[source]
94 source: reqwest::Error,
95 },
96
97 #[error("texture request for '{operation}' returned {status}: {body}")]
98 TextureStatus {
99 operation: &'static str,
100 status: reqwest::StatusCode,
101 body: String,
102 },
103
104 #[error("unknown skin model '{model}'")]
105 TextureModelUnknown { model: String },
106
107 #[error("verification handler failed")]
108 VerificationHandler {
109 #[source]
110 source: Box<dyn std::error::Error + Send + Sync>,
111 },
112
113 #[cfg(feature = "yggdrasil-auth")]
114 #[error("Yggdrasil request failed")]
115 Yggdrasil {
116 #[source]
117 source: nidhogg::error::NidhoggError,
118 },
119
120 #[cfg(feature = "yggdrasil-auth")]
121 #[error("Yggdrasil authentication response contains no Minecraft profile")]
122 YggdrasilProfileMissing,
123
124 #[cfg(feature = "yggdrasil-auth")]
125 #[error("parse Yggdrasil profile textures failed")]
126 YggdrasilTexture {
127 #[source]
128 source: nidhogg::types::profile::ProfilePropertyError,
129 },
130}
131
132pub type Result<T> = std::result::Result<T, Error>;