Skip to content

Commit

Permalink
Replace try/catch with .catch (#21763)
Browse files Browse the repository at this point in the history
  • Loading branch information
ambirdsall authored Jan 27, 2023
1 parent 01b0565 commit 819896e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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: () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,9 +245,7 @@ export const AuthenticationProvider: React.FC<React.PropsWithChildren<unknown>>
await authService.resetPassword(email);
},
async sendEmailVerification(): Promise<void> {
try {
await authService.sendEmailVerifiedLink();
} catch (error) {
return authService.sendEmailVerifiedLink().catch((error) => {
switch (error.code) {
case AuthErrorCodes.NETWORK_REQUEST_FAILED:
registerNotification({
Expand Down Expand Up @@ -276,8 +274,7 @@ export const AuthenticationProvider: React.FC<React.PropsWithChildren<unknown>>
type: ToastType.ERROR,
});
}
throw error;
}
});
},
async verifyEmail(code: string): Promise<void> {
await authService.confirmEmailVerify(code);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const EmailVerificationHint: React.FC<Props> = ({ className }) => {

const onResendVerificationMail = async () => {
// the shared error handling inside `sendEmailVerification` suffices
await sendEmailVerification().catch();
await sendEmailVerification();
setIsEmailResend(true);
};

Expand Down

0 comments on commit 819896e

Please sign in to comment.