-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/update donation person #348
Conversation
Coverage report
Test suite run success176 tests passing in 64 suites. Report generated by 🧪jest coverage report action from 5ddcba7 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great overall, pls check my comments below
const targetDonor = await this.prisma.person.findFirst({ | ||
where: { id: updatePaymentDto.targetPersonId }, | ||
}) | ||
if (!targetDonor) { | ||
throw new NotFoundException( | ||
`Update failed. No person found with ID: ${updatePaymentDto.targetPersonId}`, | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May be we can skip checking for if the targetPersonId exists, because it will be checked automatically by the ForeignKey when updating the donation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
true, but then the user will get a system unhandled exception, this way it is much more user friendly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about handling the exception. Just found that Prisma has an error code for this case P2003 and the exception docs show how to handle it: https://www.prisma.io/docs/concepts/components/prisma-client/handling-exceptions-and-errors
the backend part for: podkrepi-bg/frontend#958