From b4fd895ea29a0f277e3f001c1649a616314295e4 Mon Sep 17 00:00:00 2001 From: Alex Holliday Date: Sun, 15 Sep 2024 09:16:55 +0800 Subject: [PATCH] Add service name and method name to errors in notification and pageSpeedCheck modules --- Server/db/mongo/modules/notificationModule.js | 6 ++++++ Server/db/mongo/modules/pageSpeedCheckModule.js | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/Server/db/mongo/modules/notificationModule.js b/Server/db/mongo/modules/notificationModule.js index f5c8708f4..f2c5ecf9d 100644 --- a/Server/db/mongo/modules/notificationModule.js +++ b/Server/db/mongo/modules/notificationModule.js @@ -15,6 +15,8 @@ const createNotification = async (notificationData) => { const notification = await new Notification({ ...notificationData }).save(); return notification; } catch (error) { + error.service = SERVICE_NAME; + error.method = "createNotification"; throw error; } }; @@ -30,6 +32,8 @@ const getNotificationsByMonitorId = async (monitorId) => { const notifications = await Notification.find({ monitorId }); return notifications; } catch (error) { + error.service = SERVICE_NAME; + error.method = "getNotificationsByMonitorId"; throw error; } }; @@ -39,6 +43,8 @@ const deleteNotificationsByMonitorId = async (monitorId) => { const result = await Notification.deleteMany({ monitorId }); return result.deletedCount; } catch (error) { + error.service = SERVICE_NAME; + error.method = "deleteNotificationsByMonitorId"; throw error; } }; diff --git a/Server/db/mongo/modules/pageSpeedCheckModule.js b/Server/db/mongo/modules/pageSpeedCheckModule.js index 92f87d060..546995c2e 100644 --- a/Server/db/mongo/modules/pageSpeedCheckModule.js +++ b/Server/db/mongo/modules/pageSpeedCheckModule.js @@ -19,6 +19,8 @@ const createPageSpeedCheck = async (pageSpeedCheckData) => { }).save(); return pageSpeedCheck; } catch (error) { + error.service = SERVICE_NAME; + error.method = "createPageSpeedCheck"; throw error; } }; @@ -36,6 +38,8 @@ const getPageSpeedChecks = async (monitorId) => { const pageSpeedChecks = await PageSpeedCheck.find({ monitorId }); return pageSpeedChecks; } catch (error) { + error.service = SERVICE_NAME; + error.method = "getPageSpeedChecks"; throw error; } }; @@ -53,6 +57,8 @@ const deletePageSpeedChecksByMonitorId = async (monitorId) => { const result = await PageSpeedCheck.deleteMany({ monitorId }); return result.deletedCount; } catch (error) { + error.service = SERVICE_NAME; + error.method = "deletePageSpeedChecksByMonitorId"; throw error; } };