31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 1 | use std::sync::Arc; |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 2 | |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 3 | use matrix_sdk::{ |
1fe480c16a3c | atagen | 2026-09-26 08:44 UTC | 4 | HttpError, RefreshTokenError, SendOutsideWasm, SyncOutsideWasm, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 5 | authentication::oauth::error::{ |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 6 | OAuthAuthorizationCodeError, OAuthDiscoveryError, OAuthError, OAuthTokenRevocationError, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 7 | RequestTokenError, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 8 | }, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 9 | encryption::{ |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 10 | identities::{ManualVerifyError, RequestVerificationError}, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 11 | recovery::RecoveryError, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 12 | secret_storage::{ImportError, SecretStorageError}, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 13 | }, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 14 | }; |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 15 | #[cfg(feature = "serde")] |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 16 | use serde::{Deserialize, Serialize}; |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 17 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 18 | use crate::InteractiveAuthChallenge; |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 19 | |
1fe480c16a3c | atagen | 2026-09-26 08:44 UTC | 20 | /// the sdk's `SendOutsideWasm` isn't an auto trait, so it can't go in a trait object |
1fe480c16a3c | atagen | 2026-09-26 08:44 UTC | 21 | #[cfg(not(target_family = "wasm"))] |
62fe32759529 | atagen | 2026-09-26 08:50 UTC | 22 | pub(crate) type SourceError = dyn std::error::Error + Send + Sync; |
1fe480c16a3c | atagen | 2026-09-26 08:44 UTC | 23 | #[cfg(target_family = "wasm")] |
62fe32759529 | atagen | 2026-09-26 08:50 UTC | 24 | pub(crate) type SourceError = dyn std::error::Error; |
1fe480c16a3c | atagen | 2026-09-26 08:44 UTC | 25 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 26 | /// the one thing that goes wrong, for commands and queries alike. match on `kind`, show `message` |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 27 | #[derive(Clone, Debug, thiserror::Error)] |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 28 | #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 29 | #[error("{message}")] |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 30 | #[non_exhaustive] |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 31 | pub struct Error { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 32 | pub kind: ErrorKind, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 33 | pub message: String, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 34 | /// set when the server wants interactive auth before it'll do the thing |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 35 | pub challenge: Option<Box<InteractiveAuthChallenge>>, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 36 | #[source] |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 37 | #[cfg_attr(feature = "serde", serde(skip))] |
1fe480c16a3c | atagen | 2026-09-26 08:44 UTC | 38 | source: Option<Arc<SourceError>>, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 39 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 40 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 41 | #[derive(Clone, Copy, Debug, Eq, PartialEq)] |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 42 | #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 43 | #[non_exhaustive] |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 44 | pub enum ErrorKind { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 45 | /// the engine stopped, or the task doing the work died, before answering |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 46 | Interrupted, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 47 | Unauthenticated, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 48 | InteractiveAuthRequired, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 49 | Invalid, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 50 | RoomUnknown, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 51 | RoomNotOpen, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 52 | TimelineNotOpen, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 53 | RoomBusy, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 54 | QueueFull, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 55 | EmptyBody, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 56 | MediaUnknown, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 57 | MediaTooLarge, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 58 | MediaUnavailable, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 59 | VerificationInactive, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 60 | VerificationUnsupported, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 61 | NoCrossSigningIdentity, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 62 | RecoveryRejected, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 63 | Network, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 64 | Server, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 65 | Store, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 66 | Timeline, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 67 | Encryption, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 68 | Other, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 69 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 70 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 71 | impl Error { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 72 | pub(crate) fn new(kind: ErrorKind, message: impl Into<String>) -> Self { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 73 | Self { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 74 | kind, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 75 | message: message.into(), |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 76 | challenge: None, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 77 | source: None, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 78 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 79 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 80 | |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 81 | pub(crate) fn with_source( |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 82 | kind: ErrorKind, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 83 | message: impl Into<String>, |
1fe480c16a3c | atagen | 2026-09-26 08:44 UTC | 84 | source: impl std::error::Error + SendOutsideWasm + SyncOutsideWasm + 'static, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 85 | ) -> Self { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 86 | Self { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 87 | source: Some(Arc::new(source)), |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 88 | ..Self::new(kind, message) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 89 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 90 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 91 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 92 | pub(crate) fn interrupted() -> Self { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 93 | Self::new( |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 94 | ErrorKind::Interrupted, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 95 | "the engine stopped before the operation finished", |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 96 | ) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 97 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 98 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 99 | pub(crate) fn room_unknown() -> Self { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 100 | Self::new( |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 101 | ErrorKind::RoomUnknown, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 102 | "room is not available in the local store", |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 103 | ) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 104 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 105 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 106 | pub(crate) fn interactive_auth(challenge: InteractiveAuthChallenge) -> Self { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 107 | Self { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 108 | challenge: Some(Box::new(challenge)), |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 109 | ..Self::new( |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 110 | ErrorKind::InteractiveAuthRequired, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 111 | "interactive authentication is required", |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 112 | ) |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 113 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 114 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 115 | |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 116 | pub(crate) fn from_sdk(message: impl Into<String>, source: matrix_sdk::Error) -> Self { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 117 | Self::with_source(classify_sdk_error(&source), message, source) |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 118 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 119 | |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 120 | pub(crate) fn from_http(message: impl Into<String>, source: HttpError) -> Self { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 121 | Self::with_source(classify_http_error(&source), message, source) |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 122 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 123 | |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 124 | pub(crate) fn from_refresh_token( |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 125 | message: impl Into<String>, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 126 | source: RefreshTokenError, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 127 | ) -> Self { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 128 | Self::with_source(classify_refresh_token_error(&source), message, source) |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 129 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 130 | |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 131 | pub(crate) fn from_recovery(message: impl Into<String>, source: RecoveryError) -> Self { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 132 | let kind = match &source { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 133 | RecoveryError::Sdk(source) => classify_sdk_error(source), |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 134 | RecoveryError::SecretStorage(SecretStorageError::Sdk(source)) => { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 135 | classify_sdk_error(source) |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 136 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 137 | RecoveryError::SecretStorage(SecretStorageError::ImportError { error, .. }) => { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 138 | match error { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 139 | ImportError::Sdk(source) => classify_sdk_error(source), |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 140 | _ => ErrorKind::RecoveryRejected, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 141 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 142 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 143 | RecoveryError::SecretStorage(SecretStorageError::Verification(source)) => { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 144 | match source { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 145 | ManualVerifyError::Http(source) => classify_http_error(source), |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 146 | _ => ErrorKind::RecoveryRejected, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 147 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 148 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 149 | RecoveryError::SecretStorage(SecretStorageError::SecretStorageKey(_)) => { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 150 | ErrorKind::RecoveryRejected |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 151 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 152 | RecoveryError::SecretStorage(SecretStorageError::Storage(_)) => ErrorKind::Store, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 153 | RecoveryError::BackupExistsOnServer | RecoveryError::SecretStorage(_) => { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 154 | ErrorKind::RecoveryRejected |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 155 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 156 | }; |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 157 | Self::with_source(kind, message, source) |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 158 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 159 | |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 160 | pub(crate) fn from_verification_request( |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 161 | message: impl Into<String>, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 162 | source: RequestVerificationError, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 163 | ) -> Self { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 164 | let kind = match &source { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 165 | RequestVerificationError::Sdk(source) => classify_sdk_error(source), |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 166 | RequestVerificationError::RoomCreation(_) => ErrorKind::Encryption, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 167 | }; |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 168 | Self::with_source(kind, message, source) |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 169 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 170 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 171 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 172 | impl PartialEq for Error { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 173 | fn eq(&self, other: &Self) -> bool { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 174 | self.kind == other.kind |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 175 | && self.message == other.message |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 176 | && self.challenge == other.challenge |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 177 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 178 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 179 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 180 | pub(crate) fn classify_sdk_error(source: &matrix_sdk::Error) -> ErrorKind { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 181 | match source { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 182 | matrix_sdk::Error::Http(source) => classify_http_error(source), |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 183 | matrix_sdk::Error::OAuth(source) => classify_oauth_error(source), |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 184 | matrix_sdk::Error::AuthenticationRequired => ErrorKind::Unauthenticated, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 185 | matrix_sdk::Error::BadCryptoStoreState |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 186 | | matrix_sdk::Error::CryptoStoreError(_) |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 187 | | matrix_sdk::Error::CrossProcessLockError(_) |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 188 | | matrix_sdk::Error::StateStore(_) |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 189 | | matrix_sdk::Error::EventCacheStore(_) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 190 | | matrix_sdk::Error::MediaStore(_) => ErrorKind::Store, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 191 | matrix_sdk::Error::NoOlmMachine |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 192 | | matrix_sdk::Error::OlmError(_) |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 193 | | matrix_sdk::Error::MegolmError(_) |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 194 | | matrix_sdk::Error::DecryptorError(_) => ErrorKind::Encryption, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 195 | matrix_sdk::Error::Media(_) => ErrorKind::MediaUnavailable, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 196 | matrix_sdk::Error::Timeout => ErrorKind::Network, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 197 | _ => ErrorKind::Other, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 198 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 199 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 200 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 201 | fn classify_http_error(source: &HttpError) -> ErrorKind { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 202 | match source { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 203 | HttpError::Reqwest(_) => ErrorKind::Network, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 204 | HttpError::Api(_) => ErrorKind::Server, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 205 | HttpError::RefreshToken(source) => classify_refresh_token_error(source), |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 206 | HttpError::Cached(source) => classify_http_error(source), |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 207 | _ => ErrorKind::Other, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 208 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 209 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 210 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 211 | fn classify_refresh_token_error(source: &RefreshTokenError) -> ErrorKind { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 212 | match source { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 213 | RefreshTokenError::RefreshTokenRequired => ErrorKind::Unauthenticated, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 214 | RefreshTokenError::MatrixAuth(source) => classify_http_error(source), |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 215 | RefreshTokenError::OAuth(source) => classify_oauth_error(source), |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 216 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 217 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 218 | |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 219 | fn classify_oauth_error(source: &OAuthError) -> ErrorKind { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 220 | let classify_token_request_error = |source: &_| match source { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 221 | RequestTokenError::Request(_) => ErrorKind::Network, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 222 | RequestTokenError::ServerResponse(_) => ErrorKind::Unauthenticated, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 223 | _ => ErrorKind::Other, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 224 | }; |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 225 | match source { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 226 | OAuthError::Discovery(source) => match source { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 227 | OAuthDiscoveryError::Http(source) => classify_http_error(source), |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 228 | OAuthDiscoveryError::Oidc(source) => classify_token_request_error(source), |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 229 | _ => ErrorKind::Unauthenticated, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 230 | }, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 231 | OAuthError::RefreshToken(source) => classify_token_request_error(source), |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 232 | OAuthError::AuthorizationCode(OAuthAuthorizationCodeError::RequestToken(source)) => { |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 233 | classify_token_request_error(source) |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 234 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 235 | OAuthError::AuthorizationCode(_) => ErrorKind::Unauthenticated, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 236 | OAuthError::Logout(source) => match source { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 237 | OAuthTokenRevocationError::Revoke(RequestTokenError::Request(_)) => ErrorKind::Network, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 238 | OAuthTokenRevocationError::Revoke(RequestTokenError::ServerResponse(_)) => { |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 239 | ErrorKind::Unauthenticated |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 240 | } |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 241 | _ => ErrorKind::Other, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 242 | }, |
31ce2453c82f | atagen | 2026-09-24 13:07 UTC | 243 | _ => ErrorKind::Unauthenticated, |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 244 | } |
96fdf90aacd6 | atagen | 2026-09-08 08:24 UTC | 245 | } |