From bbcdc2f2a2bf287d19b4643eeb72668ffb261eab Mon Sep 17 00:00:00 2001 From: Alex Holliday Date: Thu, 24 Oct 2024 11:42:53 +0800 Subject: [PATCH] Add status 404 to getMonitorById error at DB level --- Server/db/mongo/modules/monitorModule.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Server/db/mongo/modules/monitorModule.js b/Server/db/mongo/modules/monitorModule.js index 5d54db393..6aefefad5 100644 --- a/Server/db/mongo/modules/monitorModule.js +++ b/Server/db/mongo/modules/monitorModule.js @@ -288,7 +288,9 @@ const getMonitorById = async (monitorId) => { try { const monitor = await Monitor.findById(monitorId); if (monitor === null || monitor === undefined) { - throw new Error(errorMessages.DB_FIND_MONITOR_BY_ID(monitorId)); + const error = new Error(errorMessages.DB_FIND_MONITOR_BY_ID(monitorId)); + error.status = 404; + throw error; } // Get notifications const notifications = await Notification.find({