Separate handling errors
Prevent res.body from being called if res is not defined. Close #16
This commit is contained in:
parent
681c0edc71
commit
7288d14fac
|
@ -24,7 +24,11 @@ module.exports.create = function (deps) {
|
||||||
function getTerms(err, res) {
|
function getTerms(err, res) {
|
||||||
var links;
|
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'));
|
return handleErr(err, 'Registration request failed: ' + res.body.toString('utf8'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue