diff --git a/CHANGELOG.md b/CHANGELOG.md index 662e1f3cf..8f465d45b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Decreased the density of the `@angular/material` tables - Improved the breadcrumb navigation style in the blog post pages for mobile +- Improved the error handling in the delete user endpoint - Improved the style of the _Changelog & License_ button on the about page - Upgraded `ionicons` from version `6.1.2` to `7.1.0` diff --git a/apps/api/src/app/user/user.service.ts b/apps/api/src/app/user/user.service.ts index 56807e10a..26736e88d 100644 --- a/apps/api/src/app/user/user.service.ts +++ b/apps/api/src/app/user/user.service.ts @@ -304,21 +304,29 @@ export class UserService { } public async deleteUser(where: Prisma.UserWhereUniqueInput): Promise { - await this.prismaService.access.deleteMany({ - where: { OR: [{ granteeUserId: where.id }, { userId: where.id }] } - }); + try { + await this.prismaService.access.deleteMany({ + where: { OR: [{ granteeUserId: where.id }, { userId: where.id }] } + }); + } catch {} - await this.prismaService.account.deleteMany({ - where: { userId: where.id } - }); + try { + await this.prismaService.account.deleteMany({ + where: { userId: where.id } + }); + } catch {} - await this.prismaService.analytics.delete({ - where: { userId: where.id } - }); + try { + await this.prismaService.analytics.delete({ + where: { userId: where.id } + }); + } catch {} - await this.prismaService.order.deleteMany({ - where: { userId: where.id } - }); + try { + await this.prismaService.order.deleteMany({ + where: { userId: where.id } + }); + } catch {} try { await this.prismaService.settings.delete({