Skip to content

Commit

Permalink
test existance of JSON keys from EuPMC before access
Browse files Browse the repository at this point in the history
  • Loading branch information
tarrow committed Feb 24, 2016
1 parent 2fa053e commit 2a2cbf9
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/eupmc.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ EuPmc.prototype.completeCallback = function(data) {

var resp = data.responseWrapper;

if(!resp.hitCount[0] || !resp.resultList[0].result) {
log.error("Malformed response from EuropePMC. Try running again.");
process.exit(1);
}

if (eupmc.first){
eupmc.first = false;
eupmc.hitcount = parseInt(resp.hitCount[0]);
Expand Down

0 comments on commit 2a2cbf9

Please sign in to comment.