From 3e12d76499198e4c19f4b98b46e92856362de3a3 Mon Sep 17 00:00:00 2001 From: Dragos-Paul Strat Date: Wed, 24 Jul 2024 14:03:52 +0300 Subject: [PATCH] feat: [589] add errors, sentry + fix wrong property --- .../organization/constants/errors.constants.ts | 9 +++++++++ .../services/organization-legal.service.ts | 15 +++++++++++---- .../organization/services/organization.service.ts | 3 +-- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/backend/src/modules/organization/constants/errors.constants.ts b/backend/src/modules/organization/constants/errors.constants.ts index a832809e..9c504819 100644 --- a/backend/src/modules/organization/constants/errors.constants.ts +++ b/backend/src/modules/organization/constants/errors.constants.ts @@ -43,6 +43,15 @@ export const ORGANIZATION_ERRORS = { message: 'Error while uploading the files', errorCode: 'ORG_010', }, + UPLOAD_NON_POLITICAL_AFFILIATION: { + message: 'Error while uploading the non political affiliation file', + errorCode: 'ORG_030', + }, + + UPLOAD_BALANCE_SHEET: { + message: 'Error while uploading the balance sheet file', + errorCode: 'ORG_031', + }, GET_REPORT: { message: 'Report not found', errorCode: 'ORG_011', diff --git a/backend/src/modules/organization/services/organization-legal.service.ts b/backend/src/modules/organization/services/organization-legal.service.ts index 0dba1487..abcf3b71 100644 --- a/backend/src/modules/organization/services/organization-legal.service.ts +++ b/backend/src/modules/organization/services/organization-legal.service.ts @@ -14,6 +14,7 @@ import { UpdateOrganizationLegalDto } from '../dto/update-organization-legal.dto import { OrganizationLegalRepository } from '../repositories'; import { ContactService } from './contact.service'; import { ORGANIZATION_FILES_DIR } from '../constants/files.constants'; +import * as Sentry from '@sentry/node'; @Injectable() export class OrganizationLegalService { @@ -78,6 +79,7 @@ export class OrganizationLegalService { error: { error }, ...ORGANIZATION_ERRORS.UPLOAD, }); + Sentry.captureException(error); if (error instanceof HttpException) { throw error; } else { @@ -111,13 +113,14 @@ export class OrganizationLegalService { } catch (error) { this.logger.error({ error: { error }, - ...ORGANIZATION_ERRORS.UPLOAD, + ...ORGANIZATION_ERRORS.UPLOAD_NON_POLITICAL_AFFILIATION, }); + Sentry.captureException(error); if (error instanceof HttpException) { throw error; } else { throw new InternalServerErrorException({ - ...ORGANIZATION_ERRORS.UPLOAD, + ...ORGANIZATION_ERRORS.UPLOAD_NON_POLITICAL_AFFILIATION, error, }); } @@ -144,13 +147,14 @@ export class OrganizationLegalService { } catch (error) { this.logger.error({ error: { error }, - ...ORGANIZATION_ERRORS.UPLOAD, + ...ORGANIZATION_ERRORS.UPLOAD_BALANCE_SHEET, }); + Sentry.captureException(error); if (error instanceof HttpException) { throw error; } else { throw new InternalServerErrorException({ - ...ORGANIZATION_ERRORS.UPLOAD, + ...ORGANIZATION_ERRORS.UPLOAD_BALANCE_SHEET, error, }); } @@ -231,6 +235,7 @@ export class OrganizationLegalService { ...ORGANIZATION_ERRORS.DELETE.STATUTE, }); + Sentry.captureException(error); const err = error?.response; throw new InternalServerErrorException({ ...ORGANIZATION_ERRORS.DELETE.STATUTE, @@ -265,6 +270,7 @@ export class OrganizationLegalService { error, ...ORGANIZATION_ERRORS.DELETE.NON_POLITICAL_AFFILIATION, }); + Sentry.captureException(error); const err = error?.response; throw new InternalServerErrorException({ @@ -300,6 +306,7 @@ export class OrganizationLegalService { ...ORGANIZATION_ERRORS.DELETE.BALANCE_SHEET, }); + Sentry.captureException(error); const err = error?.response; throw new InternalServerErrorException({ ...ORGANIZATION_ERRORS.DELETE.BALANCE_SHEET, diff --git a/backend/src/modules/organization/services/organization.service.ts b/backend/src/modules/organization/services/organization.service.ts index b8b90990..626f17bf 100644 --- a/backend/src/modules/organization/services/organization.service.ts +++ b/backend/src/modules/organization/services/organization.service.ts @@ -623,8 +623,7 @@ export class OrganizationService { await this.fileManagerService.generatePresignedURL( organization.organizationLegal.balanceSheetFile, ); - organization.organizationLegal.nonPoliticalAffiliationFile = - balanceSheetFile; + organization.organizationLegal.balanceSheetFile = balanceSheetFile; } return organization;