code: function(err, r) {
        if (err) {
          numberOfValidConnections = numberOfValidConnections - 1;
          errorObject = err;
          return false;
        } else if (r.result['$err']) {
          errorObject = r.result;
          return false;
        } else if (r.result['errmsg']) {
          errorObject = r.result;
          return false;
        } else {
          numberOfValidConnections = numberOfValidConnections + 1;
        }
  
        return true;
      }
docs: Handle the error