From f41a929976714fb74214cce7567857c53d410a21 Mon Sep 17 00:00:00 2001 From: Lizzi Lindboe Date: Thu, 17 Aug 2023 15:33:57 -0700 Subject: [PATCH] Improve GSI errors Errors that didn't have specific handling weren't being logged properly. Update logging and print all status codes so we can also see errors we aren't specifically handling. --- .../SignInButtons/GoogleSignIn/index.native.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/components/SignInButtons/GoogleSignIn/index.native.js b/src/components/SignInButtons/GoogleSignIn/index.native.js index 9e638f0723cf..099fbfde22fd 100644 --- a/src/components/SignInButtons/GoogleSignIn/index.native.js +++ b/src/components/SignInButtons/GoogleSignIn/index.native.js @@ -25,14 +25,18 @@ function googleSignInRequest() { .then((response) => response.idToken) .then((token) => Session.beginGoogleSignIn(token)) .catch((error) => { + // Handle unexpected error shape + if (error === undefined || error.code === undefined) { + Log.alert(`[Google Sign In] Google sign in failed: ${error}`); + } + /** The logged code is useful for debugging any new errors that are not specifically handled. To decode, see: + - The common status codes documentation: https://developers.google.com/android/reference/com/google/android/gms/common/api/CommonStatusCodes + - The Google Sign In codes documentation: https://developers.google.com/android/reference/com/google/android/gms/auth/api/signin/GoogleSignInStatusCodes + */ if (error.code === statusCodes.SIGN_IN_CANCELLED) { - Log.alert('[Google Sign In] Google sign in cancelled', true, {error}); - } else if (error.code === statusCodes.IN_PROGRESS) { - Log.alert('[Google Sign In] Google sign in already in progress', true, {error}); - } else if (error.code === statusCodes.PLAY_SERVICES_NOT_AVAILABLE) { - Log.alert('[Google Sign In] Google play services not available or outdated', true, {error}); + Log.info('[Google Sign In] Google Sign In cancelled'); } else { - Log.alert('[Google Sign In] Unknown Google sign in error', true, {error}); + Log.alert(`[Google Sign In] Error Code: ${error.code}. ${error.message}`, {}, false); } }); }