Add status 404 to getMonitorById error at DB level

This commit is contained in:
Alex Holliday
2024-10-24 11:42:53 +08:00
parent b69fc223bf
commit bbcdc2f2a2

View File

@@ -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({