Skip to content

Commit

Permalink
fix: remonte erreur addresse de destination invalide du back + interp…
Browse files Browse the repository at this point in the history
…rete sur le front
  • Loading branch information
Shamzic committed Oct 17, 2024
1 parent ac0eccd commit cf65a55
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
11 changes: 7 additions & 4 deletions backend/lib/messaging/sms/sms-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,13 @@ export async function sendSimulationResultsSms(
followup.smsSentAt = dayjs().toDate()
followup.smsMessageId = data.messageIds[0]
return await followup.save()
} catch (err) {
Sentry.captureException(err)
followup.smsError = JSON.stringify(err, null, 2)
throw err
} catch (error: any) {
// Avoid sending invalid destination address error to sentry
if (!error?.message?.includes("Invalid destination address")) {
Sentry.captureException(error)
}
followup.smsError = JSON.stringify(error, null, 2)
throw error
}
}

Expand Down
10 changes: 10 additions & 0 deletions src/components/modals/errors-email-and-sms-modal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@ const recapEmailState = computed(() => store.recapEmailState)
}}
</p>
</div>
<div
v-if="recapPhoneState === 'invalid-address'"
class="fr-alert fr-alert--error"
>
<p>
Une erreur s'est produite dans l'envoi du récapitulatif par SMS :
l'adresse de destination est invalide. Veuillez réessayer avec un
numéro valide ou utiliser l'envoi par email.
</p>
</div>
<div
v-if="recapPhoneState === 'ok' && recapEmailState === 'ok'"
class="fr-alert fr-alert--success"
Expand Down
10 changes: 6 additions & 4 deletions src/components/recap-email-and-sms-form.vue
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,12 @@ const sendRecap = async (surveyOptin) => {
ABTestingService.getValues().CTA_EmailRecontact
)
}
} catch (error) {
console.error(error)
Sentry.captureException(error)
} catch (error: any) {
if (!error?.response?.data?.includes("Invalid destination address")) {
Sentry.captureException(error)
} else {
store.setFormRecapPhoneState("invalid-address")
}
}
}
Expand Down Expand Up @@ -181,7 +184,6 @@ const sendRecapByEmail = async (surveyOptin) => {
store.setModalState(undefined)
await postFollowup(surveyOptin, emailValue.value)
} catch (error) {
Sentry.captureException(error)
store.setFormRecapEmailState("error")
throw error
}
Expand Down

0 comments on commit cf65a55

Please sign in to comment.