Merge pull request #26 from sharelatex/ja-wrap-track-changes-in-try-catch

Wrap RangeTracker in try catch
This commit is contained in:
James Allen 2017-03-06 19:25:16 +00:00 committed by GitHub
commit 16ebd155ec

View file

@ -13,7 +13,10 @@ module.exports = RangesManager =
if !!update.meta.tc if !!update.meta.tc
rangesTracker.setIdSeed(update.meta.tc) rangesTracker.setIdSeed(update.meta.tc)
for op in update.op for op in update.op
try
rangesTracker.applyOp(op, { user_id: update.meta?.user_id }) rangesTracker.applyOp(op, { user_id: update.meta?.user_id })
catch error
return callback(error)
if rangesTracker.changes?.length > RangesManager.MAX_CHANGES or rangesTracker.comments?.length > RangesManager.MAX_COMMENTS if rangesTracker.changes?.length > RangesManager.MAX_CHANGES or rangesTracker.comments?.length > RangesManager.MAX_COMMENTS
return callback new Error("too many comments or tracked changes") return callback new Error("too many comments or tracked changes")