From e93c649115aa3e2d7b374090ac73fb3dafb40d1c Mon Sep 17 00:00:00 2001 From: Emnaghz Date: Mon, 23 Sep 2024 16:58:19 +0100 Subject: [PATCH] fix: improve code --- api/src/user/controllers/role.controller.ts | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/api/src/user/controllers/role.controller.ts b/api/src/user/controllers/role.controller.ts index ba92870..06a366d 100644 --- a/api/src/user/controllers/role.controller.ts +++ b/api/src/user/controllers/role.controller.ts @@ -164,15 +164,11 @@ export class RoleController extends BaseController< } else if (associatedUser) { throw new ForbiddenException('Role is associated with other users'); } else { - try { - const result = await this.roleService.deleteOne(id); - if (result.deletedCount === 0) { - throw new NotFoundException(`Role with ID ${id} not found`); - } - return result; - } catch (error) { + const result = await this.roleService.deleteOne(id); + if (result.deletedCount === 0) { throw new NotFoundException(`Role with ID ${id} not found`); } + return result; } } }