error handling and protection

This commit is contained in:
MuhammadKhalilzadeh committed 2024-07-03 08:51:53 +03:30
1 parent af0ec810c9
commit 41094171f4
2 files changed
+4 -1

No files matched your search

+3
View File
@@ -107,6 +107,9 @@ const deleteUser = async (req, res) => {
const userId = req.params.userId;
try {
const deletedUser = await UserModel.findByIdAndDelete(userId);
if (!deletedUser) {
throw new Error(errorMessages.DB_USER_NOT_FOUND);
}
return deletedUser;
} catch (error) {
throw error;