Add error handling for missing contact channel in verification (#704)

…andler

- Introduced `StatusError` to handle cases where the contact channel is
not found during email verification.
- Updated the verification code handler to check for the existence of
the contact channel before attempting to update its verification status,
improving robustness and user feedback.

<!--

Make sure you've read the CONTRIBUTING.md guidelines:
https://github.com/stack-auth/stack-auth/blob/dev/CONTRIBUTING.md

-->

<!-- ELLIPSIS_HIDDEN -->


----

> [!IMPORTANT]
> Add error handling for missing contact channels in email verification
by introducing `StatusError` in `verification-code-handler.tsx`.
> 
>   - **Error Handling**:
> - Introduced `StatusError` in `verification-code-handler.tsx` to
handle missing contact channels during email verification.
> - Checks for contact channel existence before updating verification
status.
>   - **Behavior**:
> - Throws `StatusError` with message "Contact channel not found. Was
your contact channel deleted?" if contact channel is missing.
> 
> <sup>This description was created by </sup>[<img alt="Ellipsis"
src="https://img.shields.io/badge/Ellipsis-blue?color=175173">](https://www.ellipsis.dev?ref=stack-auth%2Fstack-auth&utm_source=github&utm_medium=referral)<sup>
for 49b6d43ecd. You can
[customize](https://app.ellipsis.dev/stack-auth/settings/summaries) this
summary. It will automatically update as commits are pushed.</sup>


<!-- ELLIPSIS_HIDDEN -->

---------

Co-authored-by: Konsti Wohlwend <n2d4xc@gmail.com>
Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
This commit is contained in:
Zai Shi 2025-06-27 03:35:21 +02:00 committed by GitHub
parent 8139ee926b
commit 8a4fb9245a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -60,7 +60,7 @@ export const contactChannelVerificationCodeHandler = createVerificationCodeHandl
// This happens if the email is sent but then before the user clicks the link, the contact channel is deleted.
if (!contactChannel) {
throw new StatusError(404, "Contact channel not found. Did you maybe delete your contact channel?");
throw new StatusError(400, "Contact channel not found. Was your contact channel deleted?");
}
await prismaClient.contactChannel.update({