Permalink
Browse files

null check

  • Loading branch information...
1 parent 58d2178 commit 0ec96a89bd3be8bae15d0f62ddf56e99be129163 @peterc23 committed Jul 9, 2012
Showing with 8 additions and 4 deletions.
  1. +8 −4 tracker/handlers/peersRequestHandler.js
@@ -64,12 +64,16 @@ function getStatus (req, res){
res.send(errCodes.ERR_CANNOT_RETRIEVE_PEERS, 400);
}else{
var returnList = [];
- for(var i=0; i< peerInfoList.length; i++){
- if (peerInfoList[i][tableProperties.PEERS_STATUS] == tableProperties.PEERS_CONNECTED){
- returnList.push(peerInfoList[i]);
+ if (typeof peerInfoList == 'undefined'){
+ res.send(errCodes.ERR_CANNOT_RETRIEVE_PEERS, 400);
+ }else{
+ for(var i=0; i< peerInfoList.length; i++){
+ if (peerInfoList[i][tableProperties.PEERS_STATUS] == tableProperties.PEERS_CONNECTED){
+ returnList.push(peerInfoList[i]);
+ }
}
+ res.send(returnList, 200);
}
- res.send(returnList, 200);
}
});
}catch(err){

0 comments on commit 0ec96a8

Please sign in to comment.