From 185751b6b69ba80850cf8a4b1582703347d341a2 Mon Sep 17 00:00:00 2001 From: Alex Holliday Date: Sun, 15 Sep 2024 12:13:05 +0800 Subject: [PATCH] Add service name and method name to errors in maintenanceController --- Server/controllers/maintenanceWindowController.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/Server/controllers/maintenanceWindowController.js b/Server/controllers/maintenanceWindowController.js index 5fe8ab7db..755d4c5bb 100644 --- a/Server/controllers/maintenanceWindowController.js +++ b/Server/controllers/maintenanceWindowController.js @@ -39,7 +39,10 @@ const createMaintenanceWindow = async (req, res, next) => { data: maintenanceWindow, }); } catch (error) { - error.service = SERVICE_NAME; + error.service === undefined ? (error.service = SERVICE_NAME) : null; + error.method === undefined + ? (error.method = "createMaintenanceWindow") + : null; next(error); } }; @@ -68,7 +71,10 @@ const getMaintenanceWindowsByUserId = async (req, res, next) => { data: maintenanceWindows, }); } catch (error) { - error.service = SERVICE_NAME; + error.service === undefined ? (error.service = SERVICE_NAME) : null; + error.method === undefined + ? (error.method = "getMaintenanceWindowsByUserId") + : null; next(error); } }; @@ -98,7 +104,10 @@ const getMaintenanceWindowsByMonitorId = async (req, res, next) => { data: maintenanceWindows, }); } catch (error) { - error.service = SERVICE_NAME; + error.service === undefined ? (error.service = SERVICE_NAME) : null; + error.method === undefined + ? (error.method = "getMaintenanceWindowsByMonitorId") + : null; next(error); } };