Add error handling to notifications

This commit is contained in:
Alex Holliday committed 2024-09-02 10:52:11 -07:00
1 parent 071a7fc9cf
commit 4d61ecfe35
1 file changed
+10 -2
+10 -2
View File
@@ -16,6 +16,7 @@ class NetworkService {
} }
async handleNotification(monitor, isAlive) { async handleNotification(monitor, isAlive) {
try {
let template = let template =
isAlive === true ? "serverIsUpTemplate" : "serverIsDownTemplate"; isAlive === true ? "serverIsUpTemplate" : "serverIsDownTemplate";
let status = isAlive === true ? "up" : "down"; let status = isAlive === true ? "up" : "down";
@@ -33,6 +34,13 @@ class NetworkService {
); );
} }
} }
} catch (error) {
logger.error(error.message, {
method: "handleNotification",
service: this.SERVICE_NAME,
monitorId: monitor._id,
});
}
} }
async handleStatusUpdate(job, isAlive) { async handleStatusUpdate(job, isAlive) {
@@ -42,7 +50,7 @@ class NetworkService {
if (monitor === null || monitor === undefined) { if (monitor === null || monitor === undefined) {
logger.error(`Null Monitor: ${_id}`, { logger.error(`Null Monitor: ${_id}`, {
method: "handleNotification", method: "handleStatusUpdate",
service: this.SERVICE_NAME, service: this.SERVICE_NAME,
jobId: job.id, jobId: job.id,
}); });
@@ -69,7 +77,7 @@ class NetworkService {
} }
} catch (error) { } catch (error) {
logger.error(error.message, { logger.error(error.message, {
method: "handleNotification", method: "handleStatusUpdate",
service: this.SERVICE_NAME, service: this.SERVICE_NAME,
jobId: job.id, jobId: job.id,
}); });