about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/components/ageAssurance/AgeAssuranceInitDialog.tsx20
1 files changed, 13 insertions, 7 deletions
diff --git a/src/components/ageAssurance/AgeAssuranceInitDialog.tsx b/src/components/ageAssurance/AgeAssuranceInitDialog.tsx
index 18c7641e3..08fd5f84f 100644
--- a/src/components/ageAssurance/AgeAssuranceInitDialog.tsx
+++ b/src/components/ageAssurance/AgeAssuranceInitDialog.tsx
@@ -134,16 +134,18 @@ function Inner() {
 
       setSuccess(true)
     } catch (e) {
+      let error: React.ReactNode = _(
+        msg`Something went wrong, please try again`,
+      )
+
       if (e instanceof XRPCError) {
         if (e.error === 'InvalidEmail') {
-          setError(
-            _(
-              msg`Please enter a valid, non-temporary email address. You may need to access this email in the future.`,
-            ),
+          error = _(
+            msg`Please enter a valid, non-temporary email address. You may need to access this email in the future.`,
           )
           logger.metric('ageAssurance:initDialogError', {code: 'InvalidEmail'})
         } else if (e.error === 'DidTooLong') {
-          setError(
+          error = (
             <>
               <Trans>
                 We're having issues initializing the age assurance process for
@@ -155,15 +157,19 @@ function Inner() {
                 </InlineLinkText>{' '}
                 for assistance.
               </Trans>
-            </>,
+            </>
           )
           logger.metric('ageAssurance:initDialogError', {code: 'DidTooLong'})
+        } else {
+          logger.metric('ageAssurance:initDialogError', {code: 'other'})
         }
       } else {
         const {clean, raw} = cleanError(e)
-        setError(clean || raw || _(msg`Something went wrong, please try again`))
+        error = clean || raw || error
         logger.metric('ageAssurance:initDialogError', {code: 'other'})
       }
+
+      setError(error)
     }
   }