Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

return null for error in callback #28

Merged
merged 1 commit into from

2 participants

@schloerke

The paradigm for node.js callbacks is to return a 'null' object if no errors are found for the error value.

This allows for quick

if (responseError) fix_it();

Best,
Barret

@3rd-Eden
Owner

There are probably a few more cases where i'm not returning null but false so beware of that as well if you are going to strictly check for null values.

But thanks for the pull request!

@3rd-Eden 3rd-Eden merged commit 191dac1 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 21, 2012
  1. @schloerke
This page is out of date. Refresh to see the latest.
Showing with 10 additions and 4 deletions.
  1. +10 −4 lib/memcached.js
View
14 lib/memcached.js
@@ -574,12 +574,15 @@ Client.config = {
memcached.getMulti = function getMulti(keys, callback){
var memcached = this
, responses = {}
- , errors = []
+ , errors = null
, calls
// handle multiple responses and cache them untill we receive all.
, handle = function(err, results){
- if (err) errors.push(err);
+ if (err) {
+ errors || (errors = []);
+ errors.push(err);
+ }
// add all responses to the array
(Array.isArray(results) ? results : [results]).forEach(function(value){ Utils.merge(responses, value) });
@@ -693,12 +696,15 @@ Client.config = {
private.singles = function singles(type, callback){
var memcached = this
, responses = []
- , errors = []
+ , errors = null
, calls
// handle multiple servers
, handle = function(err, results){
- if (err) errors.push(err);
+ if (err) {
+ errors || (errors = []);
+ errors.push(err);
+ }
if (results) responses = responses.concat(results);
// multi calls should ALWAYS return an array!
Something went wrong with that request. Please try again.