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) {
|
||||
error.status = 422;
|
||||
error.service = SERVICE_NAME;
|
||||
error.message = error.details[0].message;
|
||||
error.message =
|
||||
error.details?.[0]?.message || error.message || "Validation Error";
|
||||
next(error);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -48,7 +48,14 @@ const getMaintenanceWindowsByUserId = async (req, res, next) => {
|
||||
await getMaintenanceWindowsByUserIdParamValidation.validateAsync(
|
||||
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(
|
||||
req.params.userId
|
||||
);
|
||||
@@ -69,7 +76,15 @@ const getMaintenanceWindowsByMonitorId = async (req, res, next) => {
|
||||
await getMaintenanceWindowsByMonitorIdParamValidation.validateAsync(
|
||||
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(
|
||||
req.params.monitorId
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user