Add service name and method name to errors in authController

This commit is contained in:
Alex Holliday committed 2024-09-15 09:25:35 +08:00
1 parent cb80ea122f
commit be0db003ad
2 files changed
+37 -14

No files matched your search

+3 -2
View File
@@ -11,7 +11,7 @@ const {
deleteAlertParamValidation,
} = require("../validation/joi");
const { successMessages } = require("../utils/messages");
const SERVICE_NAME = "alerts";
const SERVICE_NAME = "alertController";
/**
* Creates an alert for a monitor
@@ -41,7 +41,8 @@ const createAlert = async (req, res, next) => {
.status(200)
.json({ success: true, msg: successMessages.ALERT_CREATE, data: alert });
} catch (error) {
error.service = SERVICE_NAME;
error.service === undefined ? (error.service = SERVICE_NAME) : null;
error.method === undefined ? (error.method = "createAlert") : null;
next(error);
}
};