diff --git a/server/controllers/routes/admin/cohort/deleteCohort.js b/server/controllers/routes/admin/cohort/deleteCohort.js index 93da68a7..36c77aaf 100644 --- a/server/controllers/routes/admin/cohort/deleteCohort.js +++ b/server/controllers/routes/admin/cohort/deleteCohort.js @@ -2,11 +2,17 @@ const { deleteCohort } = require('../../../../database/queries'); const cohortDelete = async (req, res, next) => { try { - await deleteCohort(req.params.cohortId); - res.json({ - StatusCode: 200, - data: { message: 'Cohort deleted successfully' }, - }); + const test = await deleteCohort(req.params.cohortId); + if (test.rowCount !== 0) { + res.json({ + StatusCode: 200, + data: { message: 'Cohort deleted successfully' }, + }); + } else { + const err = new Error(); + err.msg = 'chohrt id not found'; + next(err); + } } catch (err) { next(err); }