From 484feca65d6c55577c1a033504b859f5d8bc687e Mon Sep 17 00:00:00 2001 From: luanavfg Date: Fri, 17 Nov 2023 08:48:26 -0300 Subject: [PATCH] adjust(CC-81): adjust error treatment and test --- .../use-cases/clinic/create-clinic/create-clinic.e2e-spec.ts | 4 ++-- .../core/src/shared/errors/globalAppHttpException.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libs/core-rest-api/adapters/src/controllers/api/use-cases/clinic/create-clinic/create-clinic.e2e-spec.ts b/libs/core-rest-api/adapters/src/controllers/api/use-cases/clinic/create-clinic/create-clinic.e2e-spec.ts index 84b4ca7..bc3ea85 100644 --- a/libs/core-rest-api/adapters/src/controllers/api/use-cases/clinic/create-clinic/create-clinic.e2e-spec.ts +++ b/libs/core-rest-api/adapters/src/controllers/api/use-cases/clinic/create-clinic/create-clinic.e2e-spec.ts @@ -112,7 +112,7 @@ describe('[E2E] - Create Clinic', () => { .set('Authorization', `Bearer ${access_token}`) .send(clinic); - expect(createdClinicResponse.statusCode).toBe(500); - expect(createdClinicResponse.body.message).contain('An error occurred while processing your request'); + expect(createdClinicResponse.statusCode).toBe(400); + expect(createdClinicResponse.body.message).contain("Invalid `this.postgreSqlPrismaOrmService['clinic'].create()`"); }); }); diff --git a/libs/core-rest-api/core/src/shared/errors/globalAppHttpException.ts b/libs/core-rest-api/core/src/shared/errors/globalAppHttpException.ts index f6a1538..db0dde1 100644 --- a/libs/core-rest-api/core/src/shared/errors/globalAppHttpException.ts +++ b/libs/core-rest-api/core/src/shared/errors/globalAppHttpException.ts @@ -54,7 +54,7 @@ export class GlobalAppHttpException { exceptionMessage += ` Prisma Error Code: ${error.code}.`; } - if (error.code === 'P2002') { + if (error.code === 'P2002' || error.code === 'P2003') { // Remover linhas e espaços extras const relevantLines = error.message .split('\n')