Skip to content

Commit

Permalink
feat: Email alert for error while validating code
Browse files Browse the repository at this point in the history
  • Loading branch information
chavda-bhavik committed Jul 22, 2024
1 parent 68c3ab6 commit 7304b1f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Model } from 'mongoose';
import { Writable } from 'stream';
import { Injectable, BadRequestException } from '@nestjs/common';
import { Injectable, BadRequestException, InternalServerErrorException } from '@nestjs/common';

import { APIMessages } from '@shared/constants';
import { BaseReview } from './base-review.usecase';
Expand Down Expand Up @@ -149,6 +149,9 @@ export class DoReview extends BaseReview {
senderName: process.env.EMAIL_FROM_NAME,
});
}
if (errorEmailContents.length) {
throw new InternalServerErrorException(APIMessages.ERROR_DURING_VALIDATION);
}

await this.saveResults(response);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Model } from 'mongoose';
import { Writable } from 'stream';
import { ValidateFunction } from 'ajv';
import { Injectable, BadRequestException } from '@nestjs/common';
import { Injectable, BadRequestException, InternalServerErrorException } from '@nestjs/common';

import { ColumnDelimiterEnum, ColumnTypesEnum, ITemplateSchemaItem, UploadStatusEnum } from '@impler/shared';
import { UploadRepository, ValidatorRepository, DalService, TemplateEntity } from '@impler/dal';
Expand Down Expand Up @@ -303,6 +303,10 @@ export class DoReReview extends BaseReview {
});
}

if (errorEmailContents.length) {
throw new InternalServerErrorException(APIMessages.ERROR_DURING_VALIDATION);
}

return result;
}

Expand Down
2 changes: 2 additions & 0 deletions apps/api/src/app/shared/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ export const APIMessages = {
INVALID_AUTH_TOKEN: 'Invalid authentication token',
COLUMN_KEY_TAKEN: 'Column with the same key already exists. Please provide a unique key from "Validations".',
COLUMN_KEY_DUPLICATED: 'Column with the same key already exists. Please provide a unique key.',
ERROR_DURING_VALIDATION:
'Something went wrong while validating data. Data is not imported yet, but team is informed about issue. Please try again after sometime.',
};

export const CONSTANTS = {
Expand Down

0 comments on commit 7304b1f

Please sign in to comment.