Add service name and method name to errors in monitorController
This commit is contained in:
1 parent
185751b6b6
commit
d7e6019139
1 file changed
+32
-18
@@ -38,7 +38,8 @@ const getAllMonitors = async (req, res, next) => {
|
|||||||
data: monitors,
|
data: monitors,
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
error.service = SERVICE_NAME;
|
error.service === undefined ? (error.service = SERVICE_NAME) : null;
|
||||||
|
error.method === undefined ? (error.method = "getAllMonitors") : null;
|
||||||
next(error);
|
next(error);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -77,6 +78,10 @@ const getMonitorAggregateStats = async (req, res, next) => {
|
|||||||
data: aggregateStats,
|
data: aggregateStats,
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
error.service === undefined ? (error.service = SERVICE_NAME) : null;
|
||||||
|
error.method === undefined
|
||||||
|
? (error.method = "getMonitorAggregateStats")
|
||||||
|
: null;
|
||||||
next(error);
|
next(error);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -109,7 +114,8 @@ const getMonitorStatsById = async (req, res, next) => {
|
|||||||
data: monitorStats,
|
data: monitorStats,
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
error.service = SERVICE_NAME;
|
error.service === undefined ? (error.service = SERVICE_NAME) : null;
|
||||||
|
error.method === undefined ? (error.method = "getMonitorStatsById") : null;
|
||||||
next(error);
|
next(error);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -145,7 +151,10 @@ const getMonitorCertificate = async (req, res, next) => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
error.service = SERVICE_NAME;
|
error.service === undefined ? (error.service = SERVICE_NAME) : null;
|
||||||
|
error.method === undefined
|
||||||
|
? (error.method = "getMonitorCertificate")
|
||||||
|
: null;
|
||||||
next(error);
|
next(error);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -184,7 +193,8 @@ const getMonitorById = async (req, res, next) => {
|
|||||||
data: monitor,
|
data: monitor,
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
error.service = SERVICE_NAME;
|
error.service === undefined ? (error.service = SERVICE_NAME) : null;
|
||||||
|
error.method === undefined ? (error.method = "getMonitorById") : null;
|
||||||
next(error);
|
next(error);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -229,9 +239,10 @@ const getMonitorsAndSummaryByTeamId = async (req, res, next) => {
|
|||||||
data: monitorsSummary,
|
data: monitorsSummary,
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
error.service = SERVICE_NAME;
|
error.service === undefined ? (error.service = SERVICE_NAME) : null;
|
||||||
error.method === undefined &&
|
error.method === undefined
|
||||||
error.method === "getMonitorsAndSummaryByTeamId";
|
? (error.method = "getMonitorsAndSummaryByTeamId")
|
||||||
|
: null;
|
||||||
next(error);
|
next(error);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -267,7 +278,8 @@ const getMonitorsByTeamId = async (req, res, next) => {
|
|||||||
data: monitors,
|
data: monitors,
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
error.service = SERVICE_NAME;
|
error.service === undefined ? (error.service = SERVICE_NAME) : null;
|
||||||
|
error.method === undefined ? (error.method = "getMonitorsByTeamId") : null;
|
||||||
next(error);
|
next(error);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -316,7 +328,8 @@ const createMonitor = async (req, res, next) => {
|
|||||||
data: monitor,
|
data: monitor,
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
error.service = SERVICE_NAME;
|
error.service === undefined ? (error.service = SERVICE_NAME) : null;
|
||||||
|
error.method === undefined ? (error.method = "createMonitor") : null;
|
||||||
next(error);
|
next(error);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -361,14 +374,14 @@ const deleteMonitor = async (req, res, next) => {
|
|||||||
.status(200)
|
.status(200)
|
||||||
.json({ success: true, msg: successMessages.MONITOR_DELETE });
|
.json({ success: true, msg: successMessages.MONITOR_DELETE });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
error.service = SERVICE_NAME;
|
error.service === undefined ? (error.service = SERVICE_NAME) : null;
|
||||||
|
error.method === undefined ? (error.method = "deleteMonitor") : null;
|
||||||
next(error);
|
next(error);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const deleteAllMonitors = async (req, res) => {
|
const deleteAllMonitors = async (req, res) => {
|
||||||
try {
|
try {
|
||||||
console.log("WTF");
|
|
||||||
const token = getTokenFromHeaders(req.headers);
|
const token = getTokenFromHeaders(req.headers);
|
||||||
const { teamId } = jwt.verify(token, process.env.JWT_SECRET);
|
const { teamId } = jwt.verify(token, process.env.JWT_SECRET);
|
||||||
const { monitors, deletedCount } = await req.db.deleteAllMonitors(teamId);
|
const { monitors, deletedCount } = await req.db.deleteAllMonitors(teamId);
|
||||||
@@ -384,8 +397,8 @@ const deleteAllMonitors = async (req, res) => {
|
|||||||
.status(200)
|
.status(200)
|
||||||
.json({ success: true, msg: `Deleted ${deletedCount} monitors` });
|
.json({ success: true, msg: `Deleted ${deletedCount} monitors` });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
error.service = SERVICE_NAME;
|
error.service === undefined ? (error.service = SERVICE_NAME) : null;
|
||||||
error.method === undefined && error.method === "deleteAllMonitors";
|
error.method === undefined ? (error.method = "deleteAllMonitors") : null;
|
||||||
next(error);
|
next(error);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -441,7 +454,8 @@ const editMonitor = async (req, res, next) => {
|
|||||||
data: editedMonitor,
|
data: editedMonitor,
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
error.service = SERVICE_NAME;
|
error.service === undefined ? (error.service = SERVICE_NAME) : null;
|
||||||
|
error.method === undefined ? (error.method = "editMonitor") : null;
|
||||||
next(error);
|
next(error);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -475,8 +489,8 @@ const pauseMonitor = async (req, res, next) => {
|
|||||||
data: monitor,
|
data: monitor,
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
error.service = SERVICE_NAME;
|
error.service === undefined ? (error.service = SERVICE_NAME) : null;
|
||||||
error.method = "pauseMonitor";
|
error.method === undefined ? (error.method = "pauseMonitor") : null;
|
||||||
next(error);
|
next(error);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -495,8 +509,8 @@ const addDemoMonitors = async (req, res, next) => {
|
|||||||
data: demoMonitors.length,
|
data: demoMonitors.length,
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
error.service = SERVICE_NAME;
|
error.service === undefined ? (error.service = SERVICE_NAME) : null;
|
||||||
error.method === undefined && error.method === "addDemoMonitors";
|
error.method === undefined ? (error.method = "addDemoMonitors") : null;
|
||||||
next(error);
|
next(error);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in new issue
Block a user