mirror of
https://github.com/bluewave-labs/Checkmate.git
synced 2026-02-04 08:08:35 -06:00
Use middleware for handling errors.
This commit is contained in:
@@ -1,11 +1,10 @@
|
||||
import logger from '../utils/logger.js';
|
||||
|
||||
class NotificationController {
|
||||
constructor(notificationService) {
|
||||
this.notificationService = notificationService;
|
||||
}
|
||||
|
||||
async triggerNotification(req, res) {
|
||||
async triggerNotification(req, res, next) {
|
||||
try {
|
||||
const { monitorId, type, config } = req.body;
|
||||
|
||||
@@ -28,16 +27,9 @@ class NotificationController {
|
||||
});
|
||||
|
||||
} catch (error) {
|
||||
logger.error({
|
||||
message: error.message,
|
||||
service: "NotificationController",
|
||||
method: "triggerNotification",
|
||||
stack: error.stack,
|
||||
});
|
||||
|
||||
return res.error({
|
||||
msg: "Failed to send notification"
|
||||
});
|
||||
error.service = "NotificationController";
|
||||
error.method = "triggerNotification";
|
||||
next(error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user