From 91f9ef85aeaa9fc5b828e2c0eed19ebb7a1ded97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Commaille?= Date: Fri, 7 Mar 2025 13:57:59 +0100 Subject: [PATCH] refactor(oidc): Add type alias for oauth2 errors To have less verbose and more predictable error types. --- crates/matrix-sdk/src/authentication/oidc/error.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/crates/matrix-sdk/src/authentication/oidc/error.rs b/crates/matrix-sdk/src/authentication/oidc/error.rs index fb97b1f6b..4e9954966 100644 --- a/crates/matrix-sdk/src/authentication/oidc/error.rs +++ b/crates/matrix-sdk/src/authentication/oidc/error.rs @@ -29,6 +29,10 @@ use ruma::serde::{PartialEqAsRefStr, StringEnum}; pub use super::cross_process::CrossProcessRefreshLockError; +/// An error when interacting with the OAuth 2.0 authorization server. +pub type OauthRequestError = + RequestTokenError, StandardErrorResponse>; + /// An error when trying to parse the query of a redirect URI. #[derive(Debug, Clone, thiserror::Error)] #[non_exhaustive] @@ -79,7 +83,7 @@ pub enum OidcError { /// An error occurred interacting with the OAuth 2.0 authorization server /// while refreshing the access token. #[error("failed to refresh token: {0}")] - RefreshToken(BasicRequestTokenError>), + RefreshToken(OauthRequestError), /// An error occurred revoking an OAuth 2.0 access token. #[error("failed to log out: {0}")] @@ -162,7 +166,7 @@ pub enum OauthAuthorizationCodeError { /// An error occurred interacting with the OAuth 2.0 authorization server /// while exchanging the authorization code for an access token. #[error("failed to request token: {0}")] - RequestToken(BasicRequestTokenError>), + RequestToken(OauthRequestError), } impl From> @@ -235,5 +239,5 @@ pub enum OauthTokenRevocationError { /// An error occurred interacting with the OAuth 2.0 authorization server /// while revoking the token. #[error("failed to revoke token: {0}")] - Revoke(RequestTokenError, BasicRevocationErrorResponse>), + Revoke(OauthRequestError), }