Add service name and method name to errors in queueController
This commit is contained in:
1 parent
ef83cc79f0
commit
b886a04f97
1 file changed
+9
-5
@@ -1,4 +1,4 @@
|
|||||||
const SERVICE_NAME = "JobQueue";
|
const SERVICE_NAME = "JobQueueController";
|
||||||
|
|
||||||
const getMetrics = async (req, res, next) => {
|
const getMetrics = async (req, res, next) => {
|
||||||
try {
|
try {
|
||||||
@@ -7,7 +7,8 @@ const getMetrics = async (req, res, next) => {
|
|||||||
.status(200)
|
.status(200)
|
||||||
.json({ success: true, msg: "Metrics retrieved", data: metrics });
|
.json({ success: true, msg: "Metrics retrieved", data: metrics });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
error.service = SERVICE_NAME;
|
error.service === undefined ? (error.service = SERVICE_NAME) : null;
|
||||||
|
error.method === undefined ? (error.method = "getMetrics") : null;
|
||||||
next(error);
|
next(error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -18,7 +19,8 @@ const getJobs = async (req, res, next) => {
|
|||||||
const jobs = await req.jobQueue.getJobStats();
|
const jobs = await req.jobQueue.getJobStats();
|
||||||
return res.status(200).json({ jobs });
|
return res.status(200).json({ jobs });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
error.service = SERVICE_NAME;
|
error.service === undefined ? (error.service = SERVICE_NAME) : null;
|
||||||
|
error.method === undefined ? (error.method = "getJobs") : null;
|
||||||
next(error);
|
next(error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -29,7 +31,8 @@ const addJob = async (req, res, next) => {
|
|||||||
await req.jobQueue.addJob(Math.random().toString(36).substring(7));
|
await req.jobQueue.addJob(Math.random().toString(36).substring(7));
|
||||||
return res.send("Added job");
|
return res.send("Added job");
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
error.service = SERVICE_NAME;
|
error.service === undefined ? (error.service = SERVICE_NAME) : null;
|
||||||
|
error.method === undefined ? (error.method = "addJob") : null;
|
||||||
next(error);
|
next(error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -40,7 +43,8 @@ const obliterateQueue = async (req, res, next) => {
|
|||||||
const obliterated = await req.jobQueue.obliterate();
|
const obliterated = await req.jobQueue.obliterate();
|
||||||
return res.status(200).send("Obliterated jobs");
|
return res.status(200).send("Obliterated jobs");
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
error.service = SERVICE_NAME;
|
error.service === undefined ? (error.service = SERVICE_NAME) : null;
|
||||||
|
error.method === undefined ? (error.method = "obliterateQueue") : null;
|
||||||
next(error);
|
next(error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user