Add service name and method name to errors in maintenanceModule
This commit is contained in:
1 parent
0afba94fb4
commit
6ecbe8e1f5
1 file changed
+13
@@ -1,4 +1,5 @@
|
|||||||
const MaintenanceWindow = require("../../../models/MaintenanceWindow");
|
const MaintenanceWindow = require("../../../models/MaintenanceWindow");
|
||||||
|
const SERVICE_NAME = "maintenanceWindowModule";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Asynchronously creates a new MaintenanceWindow document and saves it to the database.
|
* Asynchronously creates a new MaintenanceWindow document and saves it to the database.
|
||||||
@@ -38,6 +39,8 @@ const createMaintenanceWindow = async (maintenanceWindowData) => {
|
|||||||
const result = maintenanceWindow.save();
|
const result = maintenanceWindow.save();
|
||||||
return result;
|
return result;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
error.service = SERVICE_NAME;
|
||||||
|
error.method = "createMaintenanceWindow";
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -59,6 +62,8 @@ const getMaintenanceWindowsByUserId = async (userId) => {
|
|||||||
const maintenanceWindows = await MaintenanceWindow.find({ userId: userId });
|
const maintenanceWindows = await MaintenanceWindow.find({ userId: userId });
|
||||||
return maintenanceWindows;
|
return maintenanceWindows;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
error.service = SERVICE_NAME;
|
||||||
|
error.method = "getMaintenanceWindowByUserId";
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -82,6 +87,8 @@ const getMaintenanceWindowsByMonitorId = async (monitorId) => {
|
|||||||
});
|
});
|
||||||
return maintenanceWindows;
|
return maintenanceWindows;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
error.service = SERVICE_NAME;
|
||||||
|
error.method = "getMaintenanceWindowsByMonitorId";
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -104,6 +111,8 @@ const deleteMaintenaceWindowById = async (maintenanceWindowId) => {
|
|||||||
await MaintenanceWindow.findByIdAndDelete(maintenanceWindowId);
|
await MaintenanceWindow.findByIdAndDelete(maintenanceWindowId);
|
||||||
return maintenanceWindow;
|
return maintenanceWindow;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
error.service = SERVICE_NAME;
|
||||||
|
error.method = "deleteMaintenaceWindowById";
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -125,6 +134,8 @@ const deleteMaintenanceWindowByMonitorId = async (monitorId) => {
|
|||||||
const result = await MaintenanceWindow.deleteMany({ monitorId: monitorId });
|
const result = await MaintenanceWindow.deleteMany({ monitorId: monitorId });
|
||||||
return result;
|
return result;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
error.service = SERVICE_NAME;
|
||||||
|
error.method = "deleteMaintenanceWindowByMonitorId";
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -146,6 +157,8 @@ const deleteMaintenanceWindowByUserId = async (userId) => {
|
|||||||
const result = await MaintenanceWindow.deleteMany({ userId: userId });
|
const result = await MaintenanceWindow.deleteMany({ userId: userId });
|
||||||
return result;
|
return result;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
error.service = SERVICE_NAME;
|
||||||
|
error.method = "deleteMaintenanceWindowByUserId";
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in new issue
Block a user