diff --git a/src/routes/apps.js b/src/routes/apps.js index 2d8b4686f..bf760a160 100644 --- a/src/routes/apps.js +++ b/src/routes/apps.js @@ -294,17 +294,16 @@ async function setMemoryLimit(req, res, next) { next(new HttpSuccess(202, { taskId: result.taskId })); } -function setCpuQuota(req, res, next) { +async function setCpuQuota(req, res, next) { assert.strictEqual(typeof req.body, 'object'); assert.strictEqual(typeof req.app, 'object'); if (typeof req.body.cpuQuota !== 'number') return next(new HttpError(400, 'cpuQuota is not a number')); - apps.setCpuQuota(req.app, req.body.cpuQuota, AuditSource.fromRequest(req), function (error, result) { - if (error) return next(BoxError.toHttpError(error)); + const [error, result] = await safe(apps.setCpuQuota(req.app, req.body.cpuQuota, AuditSource.fromRequest(req))); + if (error) return next(BoxError.toHttpError(error)); - next(new HttpSuccess(202, { taskId: result.taskId })); - }); + next(new HttpSuccess(202, { taskId: result.taskId })); } async function setAutomaticBackup(req, res, next) {