improve error handling in network service, fix username form errors

This commit is contained in:
Alex Holliday committed 2024-09-26 11:01:38 +08:00
1 parent 09fb5595ab
commit 38ee162f61
4 files changed
+29 -4

No files matched your search

+1
View File
@@ -325,6 +325,7 @@ const deleteMonitor = async (req, res, next) => {
logger.error(
`Error deleting associated records for monitor ${monitor._id} with name ${monitor.name}`,
{
method: "deleteMonitor",
service: SERVICE_NAME,
error: error.message,
}
+9 -2
View File
@@ -44,10 +44,17 @@ class NetworkService {
}
async handleStatusUpdate(job, isAlive) {
let monitor;
// Look up the monitor, if it doesn't exist, it's probably been removed, return
try {
const { _id } = job.data;
const monitor = await this.db.getMonitorById(_id);
monitor = await this.db.getMonitorById(_id);
} catch (error) {
return;
}
// Otherwise, try to update monitor status
try {
if (monitor === null || monitor === undefined) {
logger.error(`Null Monitor: ${_id}`, {
method: "handleStatusUpdate",
@@ -90,7 +97,7 @@ class NetworkService {
const endTime = Date.now();
error.responseTime = endTime - startTime;
error.service === undefined ? (error.service = SERVICE_NAME) : null;
error.mheotd === undefined
error.method === undefined
? (error.method = "measureResponseTime")
: null;
throw error;