Adding errors for non-200 api responses

This commit is contained in:
Jeffrey Morgan 2015-06-02 11:23:12 -07:00
parent 71985eaf0f
commit c43a8d5a69
1 changed files with 9 additions and 0 deletions

View File

@ -80,7 +80,11 @@ module.exports = {
data.is_recommended = true; data.is_recommended = true;
_.extend(data, repo); _.extend(data, repo);
cb(null, data); cb(null, data);
} else {
repositoryServerActions.error({error: new Error('Could not fetch repository information from Docker Hub.')});
return;
} }
}); });
}, (error, repos) => { }, (error, repos) => {
repositoryServerActions.recommendedUpdated({repos}); repositoryServerActions.recommendedUpdated({repos});
@ -135,6 +139,11 @@ module.exports = {
return; return;
} }
if (response.statusCode !== 200) {
repositoryServerActions.error({error: new Error('Could not fetch repository information from Docker Hub.')});
return;
}
let data = JSON.parse(body); let data = JSON.parse(body);
cb(null, data.results); cb(null, data.results);
}); });