Description
When a user tries to sign up with an email that already exists, the app shows a generic "Form submit encountered an error, check console" alert instead of telling the user the email is already in use.
Steps to Reproduce
- Go to signup (contact form)
- Complete the form with a valid email
- Submit successfully
- Fill out the form again with the same email
- Submit — see generic error alert
Root Cause
Frontend (/pages/patient/contactForm.vue, lines 796-800):
catch (e) {
console.log(e.statusMessage + ":");
console.log(e.data);
alert("Form submit encountered an error, check console");
}
The error is caught but only logged to console with a generic alert. There's even a // TODO make better than bandaid comment.
Backend (/server/api/contactForm/form.post.ts, line 75-77):
Uses handlePrismaError(e) from /server/utils/prismaErrors.ts which converts Prisma P2002 (unique constraint violation) into an HTTP error, but the error message doesn't specify which field caused the conflict.
Database: email String? @unique in Prisma schema enforces uniqueness at the DB level.
Fix
- In
prismaErrors.ts: detect P2002 errors on the email field and return a specific message like "An account with this email already exists"
- In
contactForm.vue: parse the error response and show field-specific error messages inline (red text under the email field) instead of a generic alert
Acceptance Criteria
Description
When a user tries to sign up with an email that already exists, the app shows a generic "Form submit encountered an error, check console" alert instead of telling the user the email is already in use.
Steps to Reproduce
Root Cause
Frontend (
/pages/patient/contactForm.vue, lines 796-800):The error is caught but only logged to console with a generic alert. There's even a
// TODO make better than bandaidcomment.Backend (
/server/api/contactForm/form.post.ts, line 75-77):Uses
handlePrismaError(e)from/server/utils/prismaErrors.tswhich converts Prisma P2002 (unique constraint violation) into an HTTP error, but the error message doesn't specify which field caused the conflict.Database:
email String? @uniquein Prisma schema enforces uniqueness at the DB level.Fix
prismaErrors.ts: detect P2002 errors on theemailfield and return a specific message like "An account with this email already exists"contactForm.vue: parse the error response and show field-specific error messages inline (red text under the email field) instead of a generic alertAcceptance Criteria