Skip to content

Commit 8746180

Browse files
committed
Patched issue #5
1 parent 241bb65 commit 8746180

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

app.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,22 @@ var cio = function (user, key) {
1313
nick: this.nick
1414
}}, function (err, httpResponse, body) {
1515
if (err) throw err;
16-
if (JSON.parse(body).status == "success") {
16+
try {
17+
var status = JSON.parse(body).status;
18+
}
19+
catch (e) {
20+
console.log(e.stack);
21+
var status="API endpoints unreachable";
22+
}
23+
if (status == "success") {
1724
this.setNick(JSON.parse(body).nick);
1825
callback(false, this.nick);
1926
}
20-
else if (JSON.parse(body).status == "Error: reference name already exists") {
27+
else if (status == "Error: reference name already exists") {
2128
callback(false, this.nick);
2229
}
2330
else {
24-
throw JSON.parse(body).status;
31+
callback(status, null);
2532
}
2633
}.bind(this));
2734
}

0 commit comments

Comments
 (0)