Handle search failures better

This commit is contained in:
Jonathan Cremin 2014-12-05 20:44:10 +00:00
parent 01b4209ba1
commit 740b125a45
3 changed files with 20 additions and 9 deletions

View file

@ -19,11 +19,10 @@ module.exports.lookupId = function(id, type) {
request.get(apiRoot + path, function(res) {
var data = JSON.parse(res.text);
if (!data.results || !data.results[0] || !data.results[0].collectionId) {
if (!data.results || data.resultCount == 0 || !data.results[0].collectionId) {
var error = new Error("Not Found");
error.status = 404;
deferred.reject(error);
return;
} else {
var result = data.results[0];