File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -13,15 +13,22 @@ var cio = function (user, key) {
13
13
nick : this . nick
14
14
} } , function ( err , httpResponse , body ) {
15
15
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" ) {
17
24
this . setNick ( JSON . parse ( body ) . nick ) ;
18
25
callback ( false , this . nick ) ;
19
26
}
20
- else if ( JSON . parse ( body ) . status == "Error: reference name already exists" ) {
27
+ else if ( status == "Error: reference name already exists" ) {
21
28
callback ( false , this . nick ) ;
22
29
}
23
30
else {
24
- throw JSON . parse ( body ) . status ;
31
+ callback ( status , null ) ;
25
32
}
26
33
} . bind ( this ) ) ;
27
34
}
You can’t perform that action at this time.
0 commit comments