From 46511d61440bf8dc67b6a982896f60e3cfd25bda Mon Sep 17 00:00:00 2001 From: Marcel Klehr Date: Thu, 10 Oct 2013 20:02:13 +0200 Subject: [PATCH] Polish the error messages of the easysync lib --- src/static/js/Changeset.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/static/js/Changeset.js b/src/static/js/Changeset.js index f9270385..5f3c0b60 100644 --- a/src/static/js/Changeset.js +++ b/src/static/js/Changeset.js @@ -42,15 +42,15 @@ exports.error = function error(msg) { }; /** - * This method is user for assertions with Messages - * if assert fails, the error function called. + * This method is used for assertions with Messages + * if assert fails, the error function is called. * @param b {boolean} assertion condition * @param msgParts {string} error to be passed if it fails */ exports.assert = function assert(b, msgParts) { if (!b) { var msg = Array.prototype.slice.call(arguments, 1).join(''); - exports.error("exports: " + msg); + exports.error("Failed assertion: " + msg); } }; @@ -281,7 +281,7 @@ exports.checkRep = function (cs) { assem.endDocument(); var normalized = exports.pack(oldLen, calcNewLen, assem.toString(), charBank); - exports.assert(normalized == cs, normalized, ' != ', cs); + exports.assert(normalized == cs, 'Invalid changeset (checkRep failed)'); return cs; } @@ -1296,7 +1296,7 @@ exports.compose = function (cs1, cs2, pool) { var unpacked2 = exports.unpack(cs2); var len1 = unpacked1.oldLen; var len2 = unpacked1.newLen; - exports.assert(len2 == unpacked2.oldLen, "mismatched composition"); + exports.assert(len2 == unpacked2.oldLen, "mismatched composition of two changesets"); var len3 = unpacked2.newLen; var bankIter1 = exports.stringIterator(unpacked1.charBank); var bankIter2 = exports.stringIterator(unpacked2.charBank); @@ -2010,7 +2010,7 @@ exports.follow = function (cs1, cs2, reverseInsertOrder, pool) { var unpacked2 = exports.unpack(cs2); var len1 = unpacked1.oldLen; var len2 = unpacked2.oldLen; - exports.assert(len1 == len2, "mismatched follow"); + exports.assert(len1 == len2, "mismatched follow - cannot transform cs1 on top of cs2"); var chars1 = exports.stringIterator(unpacked1.charBank); var chars2 = exports.stringIterator(unpacked2.charBank); @@ -2190,7 +2190,7 @@ exports.composeWithDeletions = function (cs1, cs2, pool) { var unpacked2 = exports.unpack(cs2); var len1 = unpacked1.oldLen; var len2 = unpacked1.newLen; - exports.assert(len2 == unpacked2.oldLen, "mismatched composition"); + exports.assert(len2 == unpacked2.oldLen, "mismatched composition of two changesets"); var len3 = unpacked2.newLen; var bankIter1 = exports.stringIterator(unpacked1.charBank); var bankIter2 = exports.stringIterator(unpacked2.charBank);