Handle bad state if task is already stopped

This commit is contained in:
Girish Ramakrishnan
2018-11-29 23:10:15 -08:00
parent fca0e897b2
commit 9f4226093b
2 changed files with 5 additions and 1 deletions
+1
View File
@@ -21,6 +21,7 @@ function stopTask(req, res, next) {
tasks.stopTask(req.params.taskId, auditSource(req), function (error) {
if (error && error.reason === TaskError.NOT_FOUND) return next(new HttpError(404, 'No such task'));
if (error && error.reason === TaskError.BAD_STATE) return next(new HttpError(409, error.message));
if (error) return next(new HttpError(500, error));
next(new HttpSuccess(204, {}));