From 819896ee1e40e000afc8cbffbd1eb8294ffcd6e2 Mon Sep 17 00:00:00 2001 From: Alex Birdsall Date: Fri, 27 Jan 2023 11:39:35 -0800 Subject: [PATCH] Replace try/catch with .catch (#21763) --- .../EnrollmentModal/useShowEnrollmentModal.tsx | 16 +++++++--------- .../packages/cloud/services/auth/AuthService.tsx | 7 ++----- .../components/EmailVerificationHint.tsx | 2 +- 3 files changed, 10 insertions(+), 15 deletions(-) diff --git a/airbyte-webapp/src/packages/cloud/components/experiments/FreeConnectorProgram/EnrollmentModal/useShowEnrollmentModal.tsx b/airbyte-webapp/src/packages/cloud/components/experiments/FreeConnectorProgram/EnrollmentModal/useShowEnrollmentModal.tsx index bf1849e28d7a..4f5ae8b59047 100644 --- a/airbyte-webapp/src/packages/cloud/components/experiments/FreeConnectorProgram/EnrollmentModal/useShowEnrollmentModal.tsx +++ b/airbyte-webapp/src/packages/cloud/components/experiments/FreeConnectorProgram/EnrollmentModal/useShowEnrollmentModal.tsx @@ -19,15 +19,13 @@ export const useShowEnrollmentModal = () => { const { registerNotification } = useNotificationService(); const verifyEmail = () => - sendEmailVerification() - .then(() => { - registerNotification({ - id: "fcp/verify-email", - text: formatMessage({ id: "freeConnectorProgram.enrollmentModal.validationEmailConfirmation" }), - type: ToastType.INFO, - }); - }) - .catch(); // don't crash the page on error + sendEmailVerification().then(() => { + registerNotification({ + id: "fcp/verify-email", + text: formatMessage({ id: "freeConnectorProgram.enrollmentModal.validationEmailConfirmation" }), + type: ToastType.INFO, + }); + }); return { showEnrollmentModal: () => { diff --git a/airbyte-webapp/src/packages/cloud/services/auth/AuthService.tsx b/airbyte-webapp/src/packages/cloud/services/auth/AuthService.tsx index 2c2f62edd4c0..549814e435db 100644 --- a/airbyte-webapp/src/packages/cloud/services/auth/AuthService.tsx +++ b/airbyte-webapp/src/packages/cloud/services/auth/AuthService.tsx @@ -245,9 +245,7 @@ export const AuthenticationProvider: React.FC> await authService.resetPassword(email); }, async sendEmailVerification(): Promise { - try { - await authService.sendEmailVerifiedLink(); - } catch (error) { + return authService.sendEmailVerifiedLink().catch((error) => { switch (error.code) { case AuthErrorCodes.NETWORK_REQUEST_FAILED: registerNotification({ @@ -276,8 +274,7 @@ export const AuthenticationProvider: React.FC> type: ToastType.ERROR, }); } - throw error; - } + }); }, async verifyEmail(code: string): Promise { await authService.confirmEmailVerify(code); diff --git a/airbyte-webapp/src/packages/cloud/views/credits/CreditsPage/components/EmailVerificationHint.tsx b/airbyte-webapp/src/packages/cloud/views/credits/CreditsPage/components/EmailVerificationHint.tsx index 1c1f02ebb0a2..93345425b464 100644 --- a/airbyte-webapp/src/packages/cloud/views/credits/CreditsPage/components/EmailVerificationHint.tsx +++ b/airbyte-webapp/src/packages/cloud/views/credits/CreditsPage/components/EmailVerificationHint.tsx @@ -31,7 +31,7 @@ export const EmailVerificationHint: React.FC = ({ className }) => { const onResendVerificationMail = async () => { // the shared error handling inside `sendEmailVerification` suffices - await sendEmailVerification().catch(); + await sendEmailVerification(); setIsEmailResend(true); };