Merge pull request #1928 from ether/fix/easysync-error-messages
Polish the error messages of the easysync lib
This commit is contained in:
commit
c5890adf6f
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue