From 0bd3aefb9ecfdbc62072dcae7fd129b98e466b79 Mon Sep 17 00:00:00 2001 From: Mathias Jakobsen Date: Mon, 4 Mar 2024 10:35:09 +0000 Subject: [PATCH] Merge pull request #17135 from overleaf/mj-ranges-tracker-error-logs [ranges-tracker] Move data out of error message GitOrigin-RevId: 9745661cf75eaed28a133e1ad5eba0bf77d6ecc3 --- libraries/ranges-tracker/index.cjs | 18 +++--------------- .../js/RangesManager/RangesManagerTests.js | 4 +--- 2 files changed, 4 insertions(+), 18 deletions(-) diff --git a/libraries/ranges-tracker/index.cjs b/libraries/ranges-tracker/index.cjs index b7bf3330ab..b02203221b 100644 --- a/libraries/ranges-tracker/index.cjs +++ b/libraries/ranges-tracker/index.cjs @@ -195,22 +195,14 @@ class RangesTracker { if (change.op.i != null) { content = text.slice(change.op.p, change.op.p + change.op.i.length) if (content !== change.op.i) { - throw new Error( - `Change (${JSON.stringify( - change - )}) doesn't match text (${JSON.stringify(content)})` - ) + throw new Error('insertion does not match text in document') } } } for (const comment of this.comments) { content = text.slice(comment.op.p, comment.op.p + comment.op.c.length) if (content !== comment.op.c) { - throw new Error( - `Comment (${JSON.stringify( - comment - )}) doesn't match text (${JSON.stringify(content)})` - ) + throw new Error('comment does not match text in document') } } } @@ -709,11 +701,7 @@ class RangesTracker { modification.p + modification.d.length ) !== modification.d ) { - throw new Error( - `deleted content does not match. content: ${JSON.stringify( - content - )}; modification: ${JSON.stringify(modification)}` - ) + throw new Error('deletion does not match text in document') } content = content.slice(0, modification.p) + diff --git a/services/document-updater/test/unit/js/RangesManager/RangesManagerTests.js b/services/document-updater/test/unit/js/RangesManager/RangesManagerTests.js index 2032c21273..207d5b771d 100644 --- a/services/document-updater/test/unit/js/RangesManager/RangesManagerTests.js +++ b/services/document-updater/test/unit/js/RangesManager/RangesManagerTests.js @@ -179,9 +179,7 @@ describe('RangesManager', function () { this.updates, this.newDocLines ) - }).to.throw( - 'Change ({"id":"1","op":{"i":"five","p":15},"metadata":{"user_id":"user-id-123"}}) doesn\'t match text ("our ")' - ) + }).to.throw('insertion does not match text in document') }) })