MaintenanceWindowController error handling
This commit is contained in:
1 parent
abf0b5856b
commit
c478298631
1 file changed
+18
-3
@@ -15,9 +15,9 @@ const createMaintenanceWindow = async (req, res, next) => {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
error.status = 422;
|
error.status = 422;
|
||||||
error.service = SERVICE_NAME;
|
error.service = SERVICE_NAME;
|
||||||
error.message = error.details[0].message;
|
error.message =
|
||||||
|
error.details?.[0]?.message || error.message || "Validation Error";
|
||||||
next(error);
|
next(error);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -48,7 +48,14 @@ const getMaintenanceWindowsByUserId = async (req, res, next) => {
|
|||||||
await getMaintenanceWindowsByUserIdParamValidation.validateAsync(
|
await getMaintenanceWindowsByUserIdParamValidation.validateAsync(
|
||||||
req.params
|
req.params
|
||||||
);
|
);
|
||||||
|
} catch (error) {
|
||||||
|
error.status = 422;
|
||||||
|
error.service = SERVICE_NAME;
|
||||||
|
error.message =
|
||||||
|
error.details?.[0]?.message || error.message || "Validation Error";
|
||||||
|
next(error);
|
||||||
|
}
|
||||||
|
try {
|
||||||
const maintenanceWindows = await req.db.getMaintenanceWindowsByUserId(
|
const maintenanceWindows = await req.db.getMaintenanceWindowsByUserId(
|
||||||
req.params.userId
|
req.params.userId
|
||||||
);
|
);
|
||||||
@@ -69,7 +76,15 @@ const getMaintenanceWindowsByMonitorId = async (req, res, next) => {
|
|||||||
await getMaintenanceWindowsByMonitorIdParamValidation.validateAsync(
|
await getMaintenanceWindowsByMonitorIdParamValidation.validateAsync(
|
||||||
req.params
|
req.params
|
||||||
);
|
);
|
||||||
|
} catch (error) {
|
||||||
|
error.status = 422;
|
||||||
|
error.service = SERVICE_NAME;
|
||||||
|
error.message =
|
||||||
|
error.details?.[0]?.message || error.message || "Validation Error";
|
||||||
|
next(error);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
const maintenanceWindows = await req.db.getMaintenanceWindowsByMonitorId(
|
const maintenanceWindows = await req.db.getMaintenanceWindowsByMonitorId(
|
||||||
req.params.monitorId
|
req.params.monitorId
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in new issue
Block a user