From d3d11594f3d00dd1f0dace17538883e93e1bc50f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Commaille?= Date: Tue, 2 Apr 2024 15:56:13 +0200 Subject: [PATCH] Create the AccountManagementError enum MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Otherwise it forces dependant crates to add serde_urlencoded as a dependency just to be able to forward the error type. Signed-off-by: Kévin Commaille --- crates/oidc-client/src/error.rs | 11 +++++++++++ crates/oidc-client/src/requests/account_management.rs | 4 +++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/crates/oidc-client/src/error.rs b/crates/oidc-client/src/error.rs index 0c8972f9..955750b2 100644 --- a/crates/oidc-client/src/error.rs +++ b/crates/oidc-client/src/error.rs @@ -64,6 +64,9 @@ pub enum Error { /// An error occurred introspecting a token. Introspection(#[from] IntrospectionError), + + /// An error occurred building the account management URL. + AccountManagement(#[from] AccountManagementError), } /// All possible errors when fetching provider metadata. @@ -703,3 +706,11 @@ pub enum CredentialsError { #[error(transparent)] Custom(BoxError), } + +/// All errors that can occur when building the account management URL. +#[derive(Debug, Error)] +pub enum AccountManagementError { + /// An error occurred serializing the parameters. + #[error(transparent)] + UrlEncoded(#[from] serde_urlencoded::ser::Error), +} diff --git a/crates/oidc-client/src/requests/account_management.rs b/crates/oidc-client/src/requests/account_management.rs index b76314c7..849cacf2 100644 --- a/crates/oidc-client/src/requests/account_management.rs +++ b/crates/oidc-client/src/requests/account_management.rs @@ -20,6 +20,8 @@ use serde::Serialize; use serde_with::skip_serializing_none; use url::Url; +use crate::error::AccountManagementError; + /// An account management action that a user can take, including a device ID for /// the actions that support it. #[derive(Debug, Clone, PartialEq, Eq, Serialize)] @@ -101,7 +103,7 @@ pub fn build_account_management_url( mut account_management_uri: Url, action: Option, id_token_hint: Option, -) -> Result { +) -> Result { let data = AccountManagementData { action, id_token_hint,