Move UpdaterError to BoxError
This commit is contained in:
@@ -27,8 +27,7 @@ let assert = require('assert'),
|
||||
HttpError = require('connect-lastmile').HttpError,
|
||||
HttpSuccess = require('connect-lastmile').HttpSuccess,
|
||||
updater = require('../updater.js'),
|
||||
updateChecker = require('../updatechecker.js'),
|
||||
UpdaterError = require('../updater.js').UpdaterError;
|
||||
updateChecker = require('../updatechecker.js');
|
||||
|
||||
function toHttpError(error) {
|
||||
switch (error.reason) {
|
||||
@@ -79,8 +78,8 @@ function update(req, res, next) {
|
||||
|
||||
// this only initiates the update, progress can be checked via the progress route
|
||||
updater.updateToLatest(req.body, auditSource.fromRequest(req), function (error, taskId) {
|
||||
if (error && error.reason === UpdaterError.ALREADY_UPTODATE) return next(new HttpError(422, error.message));
|
||||
if (error && error.reason === UpdaterError.BAD_STATE) return next(new HttpError(409, error.message));
|
||||
if (error && error.reason === BoxError.NOT_FOUND) return next(new HttpError(422, error.message));
|
||||
if (error && error.reason === BoxError.BAD_STATE) return next(new HttpError(409, error.message));
|
||||
if (error) return next(new HttpError(500, error));
|
||||
|
||||
next(new HttpSuccess(202, { taskId }));
|
||||
|
||||
Reference in New Issue
Block a user