Polish the error messages of the easysync lib
parent
d86d99bc16
commit
46511d6144
|
@ -42,15 +42,15 @@ exports.error = function error(msg) {
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is user for assertions with Messages
|
* This method is used for assertions with Messages
|
||||||
* if assert fails, the error function called.
|
* if assert fails, the error function is called.
|
||||||
* @param b {boolean} assertion condition
|
* @param b {boolean} assertion condition
|
||||||
* @param msgParts {string} error to be passed if it fails
|
* @param msgParts {string} error to be passed if it fails
|
||||||
*/
|
*/
|
||||||
exports.assert = function assert(b, msgParts) {
|
exports.assert = function assert(b, msgParts) {
|
||||||
if (!b) {
|
if (!b) {
|
||||||
var msg = Array.prototype.slice.call(arguments, 1).join('');
|
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();
|
assem.endDocument();
|
||||||
var normalized = exports.pack(oldLen, calcNewLen, assem.toString(), charBank);
|
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;
|
return cs;
|
||||||
}
|
}
|
||||||
|
@ -1296,7 +1296,7 @@ exports.compose = function (cs1, cs2, pool) {
|
||||||
var unpacked2 = exports.unpack(cs2);
|
var unpacked2 = exports.unpack(cs2);
|
||||||
var len1 = unpacked1.oldLen;
|
var len1 = unpacked1.oldLen;
|
||||||
var len2 = unpacked1.newLen;
|
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 len3 = unpacked2.newLen;
|
||||||
var bankIter1 = exports.stringIterator(unpacked1.charBank);
|
var bankIter1 = exports.stringIterator(unpacked1.charBank);
|
||||||
var bankIter2 = exports.stringIterator(unpacked2.charBank);
|
var bankIter2 = exports.stringIterator(unpacked2.charBank);
|
||||||
|
@ -2010,7 +2010,7 @@ exports.follow = function (cs1, cs2, reverseInsertOrder, pool) {
|
||||||
var unpacked2 = exports.unpack(cs2);
|
var unpacked2 = exports.unpack(cs2);
|
||||||
var len1 = unpacked1.oldLen;
|
var len1 = unpacked1.oldLen;
|
||||||
var len2 = unpacked2.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 chars1 = exports.stringIterator(unpacked1.charBank);
|
||||||
var chars2 = exports.stringIterator(unpacked2.charBank);
|
var chars2 = exports.stringIterator(unpacked2.charBank);
|
||||||
|
|
||||||
|
@ -2190,7 +2190,7 @@ exports.composeWithDeletions = function (cs1, cs2, pool) {
|
||||||
var unpacked2 = exports.unpack(cs2);
|
var unpacked2 = exports.unpack(cs2);
|
||||||
var len1 = unpacked1.oldLen;
|
var len1 = unpacked1.oldLen;
|
||||||
var len2 = unpacked1.newLen;
|
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 len3 = unpacked2.newLen;
|
||||||
var bankIter1 = exports.stringIterator(unpacked1.charBank);
|
var bankIter1 = exports.stringIterator(unpacked1.charBank);
|
||||||
var bankIter2 = exports.stringIterator(unpacked2.charBank);
|
var bankIter2 = exports.stringIterator(unpacked2.charBank);
|
||||||
|
|
Loading…
Reference in New Issue