mirror of
https://github.com/hexastack/hexabot
synced 2024-11-28 06:52:20 +00:00
fix: improve code
This commit is contained in:
parent
d2f61eebcd
commit
e93c649115
@ -164,15 +164,11 @@ export class RoleController extends BaseController<
|
|||||||
} else if (associatedUser) {
|
} else if (associatedUser) {
|
||||||
throw new ForbiddenException('Role is associated with other users');
|
throw new ForbiddenException('Role is associated with other users');
|
||||||
} else {
|
} else {
|
||||||
try {
|
|
||||||
const result = await this.roleService.deleteOne(id);
|
const result = await this.roleService.deleteOne(id);
|
||||||
if (result.deletedCount === 0) {
|
if (result.deletedCount === 0) {
|
||||||
throw new NotFoundException(`Role with ID ${id} not found`);
|
throw new NotFoundException(`Role with ID ${id} not found`);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
} catch (error) {
|
|
||||||
throw new NotFoundException(`Role with ID ${id} not found`);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user