From 687bef9228c03ad1cd31b9c7b2e7b733fbd3f2db Mon Sep 17 00:00:00 2001 From: Dominic Date: Mon, 4 Dec 2023 10:28:32 +0100 Subject: [PATCH] Apply suggestions from code review Co-authored-by: Andrei <92177534+andrei-21@users.noreply.github.com> --- honey-badger/src/provider.rs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/honey-badger/src/provider.rs b/honey-badger/src/provider.rs index 1883eb4..ce6b083 100644 --- a/honey-badger/src/provider.rs +++ b/honey-badger/src/provider.rs @@ -50,10 +50,10 @@ impl TryInto for ServiceProviderEnum { match self { ServiceProviderEnum::LIPA_WALLET => Ok(TermsAndConditions::Lipa), ServiceProviderEnum::POCKET_EXCHANGE => Ok(TermsAndConditions::Pocket), - ServiceProviderEnum::Other(v) => Err(runtime_error( + ServiceProviderEnum::Other(v) => runtime_error!( GraphQlRuntimeErrorCode::CorruptData, - format!("Unknown service provider: {v:?}"), - )), + "Unknown service provider: {v:?}", + ), } } } @@ -145,11 +145,12 @@ impl AuthProvider { terms: TermsAndConditions, ) -> Result { info!("Requesting T&C status ({terms:?})..."); - if self.auth_level != AuthLevel::Pseudonymous { - return Err(invalid_input( - "Requesting T&C status not supported for auth levels other than Pseudonymous", - )); - } + ensure!( + self.auth_level == AuthLevel::Pseudonymous, + invalid_input( + "Requesting T&C status not supported for auth levels other than Pseudonymous" + ) + ); let variables = get_terms_and_conditions_status::Variables { service_provider: terms.into(),