Skip to content

Commit

Permalink
Throw more informative errors in three locations
Browse files Browse the repository at this point in the history
  • Loading branch information
fbennett committed Mar 20, 2018
1 parent 0887f02 commit 048fc12
Showing 1 changed file with 28 additions and 3 deletions.
31 changes: 28 additions & 3 deletions src/api_cite.js
Expand Up @@ -153,14 +153,32 @@ CSL.Engine.prototype.processCitationCluster = function (citation, citationsPre,
for (var i = 0, ilen = citationsPre.length; i < ilen; i += 1) {
c = citationsPre[i];
//CSL.debug(" -- attempting to access Pre citation with ID: ("+c[0]+")");
this.registry.citationreg.citationById[c[0]].properties.noteIndex = c[1];
try {
this.registry.citationreg.citationById[c[0]].properties.noteIndex = c[1];
} catch (e) {
var err = "CSL error\n";
err += " " + e + "\n";
err += " citationID=" + c[0] + "\n";
err += " noteIndex=" + c[1] + "\n";
err += " in array citationsPre at index " + i + ", document position " + i;
throw err;
}
citationByIndex.push(this.registry.citationreg.citationById[c[0]]);
}
citationByIndex.push(citation);
for (var i = 0, ilen = citationsPost.length; i < ilen; i += 1) {
c = citationsPost[i];
//CSL.debug(" -- attempting to access Post citation with ID: ("+c[0]+")");
this.registry.citationreg.citationById[c[0]].properties.noteIndex = c[1];
try {
this.registry.citationreg.citationById[c[0]].properties.noteIndex = c[1];
} catch (e) {
var err = "CSL error\n";
err += " " + e + "\n";
err += " citationID=" + c[0] + "\n";
err += " noteIndex=" + c[1] + "\n";
err += " in array citationsPost at index " + i + ", document position " + (citationsPre.length + 1 + i);
throw err;
}
citationByIndex.push(this.registry.citationreg.citationById[c[0]]);
}
this.registry.citationreg.citationByIndex = citationByIndex;
Expand Down Expand Up @@ -410,7 +428,14 @@ CSL.Engine.prototype.processCitationCluster = function (citation, citationsPre,
var suprame = false;
// XXX Ugly, but This is used in the second else-if branch condition below.
if (j > 0) {
oldlastid = citations[j - 1].sortedItems.slice(-1)[0][1].id;
try {
oldlastid = citations[j - 1].sortedItems.slice(-1)[0][1].id;
} catch (e) {
var err = "CSL Error\n";
err += " " + e;
err += " in citation object " + citations[j - 1].citationID + " at index " + (j - 1);
throw err;
}
if (citations[j - 1].sortedItems[0].slice(-1)[0].legislation_id) {
oldlastid = citations[j - 1].sortedItems[0].slice(-1)[0].legislation_id;
}
Expand Down

0 comments on commit 048fc12

Please sign in to comment.