Separate handling errors

Prevent res.body from being called if res is not defined.
Close #16
This commit is contained in:
Drew Warren 2017-01-17 12:01:02 -07:00
parent 681c0edc71
commit 7288d14fac
1 changed files with 5 additions and 1 deletions

View File

@ -24,7 +24,11 @@ module.exports.create = function (deps) {
function getTerms(err, res) {
var links;
if (err || Math.floor(res.statusCode/100)!==2) {
if (err) {
return handleErr(err, 'Registration request failed: ' + err.toString());
}
if (Math.floor(res.statusCode/100)!==2) {
return handleErr(err, 'Registration request failed: ' + res.body.toString('utf8'));
}