Merge pull request #2985 from overleaf/msm-oerror-remove-unprocessable-entity-error

Replace UnprocessableEntityError with calls to unprocessableEntity() handler

GitOrigin-RevId: 4bba389c8cdf87a40137d49db571fa81aaac4239
This commit is contained in:
Miguel Serrano
2020-07-16 08:47:46 +02:00
committed by Copybot
parent 397bd034c7
commit 6562f3003d
8 changed files with 167 additions and 51 deletions

View File

@@ -12,6 +12,7 @@ const PrivilegeLevels = require('../Authorization/PrivilegeLevels')
const TokenAccessHandler = require('../TokenAccess/TokenAccessHandler')
const AuthenticationController = require('../Authentication/AuthenticationController')
const Errors = require('../Errors/Errors')
const HttpErrorHandler = require('../Errors/HttpErrorHandler')
const ProjectEntityUpdateHandler = require('../Project/ProjectEntityUpdateHandler')
const { expressify } = require('../../util/promises')
@@ -272,11 +273,11 @@ async function convertDocToFile(req, res, next) {
info: { public: { message: 'Document not found' } }
})
} else if (err instanceof Errors.DocHasRangesError) {
throw new HttpErrors.UnprocessableEntityError({
info: {
public: { message: 'Document has comments or tracked changes' }
}
})
return HttpErrorHandler.unprocessableEntity(
req,
res,
'Document has comments or tracked changes'
)
} else {
throw err
}