From ec92b97e88736e6d4fdcf91ec30738ab471abe8e Mon Sep 17 00:00:00 2001 From: coezbek Date: Tue, 30 Nov 2021 00:04:04 +0100 Subject: [PATCH] Unwrap OAuth2::Error In case an error is raised within the OAuth2 request() it would make sense to forward the error kind. --- lib/omniauth/strategies/oauth2.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/omniauth/strategies/oauth2.rb b/lib/omniauth/strategies/oauth2.rb index e445214..3ef1ede 100644 --- a/lib/omniauth/strategies/oauth2.rb +++ b/lib/omniauth/strategies/oauth2.rb @@ -92,8 +92,10 @@ def callback_phase # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexi self.access_token = access_token.refresh! if access_token.expired? super end - rescue ::OAuth2::Error, CallbackError => e - fail!(:invalid_credentials, e) + rescue ::OAuth2::Error => e + fail!(e.code, e) + rescue ::CallbackError => e + fail!(e.error, e) rescue ::Timeout::Error, ::Errno::ETIMEDOUT => e fail!(:timeout, e) rescue ::SocketError => e