From 74b605c7784b70b1bd222ed2f16096e7cd947bed Mon Sep 17 00:00:00 2001 From: Sergey Elpashev Date: Fri, 9 Feb 2024 23:01:37 +0300 Subject: [PATCH] Fixed exception handling in user module --- backend/src/modules/user/user.service.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/backend/src/modules/user/user.service.ts b/backend/src/modules/user/user.service.ts index 96c1ad2..59a3839 100644 --- a/backend/src/modules/user/user.service.ts +++ b/backend/src/modules/user/user.service.ts @@ -22,8 +22,10 @@ export class UserService { return user; } catch (error) { this.logger.debug(`[user.getUser] ${JSON.stringify({ error })}`); + throw new HttpException('Internal Server Error', HttpStatus.INTERNAL_SERVER_ERROR); } } + async banUser(id: string) { try { this.logger.debug(`[user.banUser] id: ${JSON.stringify(id)}`); @@ -40,6 +42,7 @@ export class UserService { return user; } catch (error) { this.logger.debug(`[user.banUser] ${JSON.stringify({ error })}`); + throw new HttpException('Error occurred', HttpStatus.INTERNAL_SERVER_ERROR); } } @@ -60,6 +63,9 @@ export class UserService { throw error; } this.logger.debug(`[user.deBanUser] ${JSON.stringify({ error })}`); + throw new HttpException(`Error occurred`, HttpStatus.INTERNAL_SERVER_ERROR); + } + } async getBannedUsers() { try {