Skip to content

Commit

Permalink
fix: replaced some with find to simplify the check for employee exist…
Browse files Browse the repository at this point in the history
…ence
  • Loading branch information
rahul-rocket committed Feb 17, 2025
1 parent 5eb8881 commit 0574b59
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,14 @@ export class TaskCreateHandler implements ICommandHandler<TaskCreateCommand> {
const employee = await this._employeeService.findOneByIdString(employeeId);

// Automatically add the current employee to members if not already included
if (employee && !members.some((member) => member.id === employeeId)) {
if (employee && !members.find((member) => member.id === employeeId)) {
members.push(employee);
}
} catch (error) {
this.logger.error(`Unable to retrieve employee for ID: ${employeeId}. Reason: ${error.message}`);
this.logger.error(
`Unable to retrieve employee for ID: ${employeeId}. Error: ${error.message}`,
error.stack
);
throw new HttpException(
'Error while retrieving employee information',
HttpStatus.INTERNAL_SERVER_ERROR
Expand Down

0 comments on commit 0574b59

Please sign in to comment.