lib/utils.js
function cleanCallback(errorCallback, callback){
  var self = this || {};
  if(!callback){
    return function(err){ // remove other variables
      if(err && self.log){
        self.log('error',err);
      }
      errorCallback(err);
    }
  }
  
  return function(err){
    if(err){
      if(self.log){
        self.log('error',err);
      }
      errorCallback(err);
      return;
    }
    callback.apply(callback, Array.prototype.slice.call(arguments,1));
  }
}
function cleanCallback(errorCallback, callback){
  var self = this || {};
  if(!callback){
    return function(err){ // remove other variables
      if(err && self.log){
        self.log('error',err);
      }
      errorCallback(err);
    }
  }
  
  return function(err){
    if(err){
      if(self.log){
        self.log('error',err);
      }
      errorCallback(err);
      return;
    }
    callback.apply(callback, Array.prototype.slice.call(arguments,1));
  }
}
function cleanCallback ( errorCallback , callback ) { var self = this || { } ; if ( ! callback ) { return function ( err ) { // remove other variables if ( err && self . log ) { self . log ( 'error' , err ) ; } errorCallback ( err ) ; } } return function ( err ) { if ( err ) { if ( self . log ) { self . log ( 'error' , err ) ; } errorCallback ( err ) ; return ; } callback . apply ( callback , Array . prototype . slice . call ( arguments , 1 ) ) ; } }
Function for wraping callback to handle errors

@param {Function} errorCallback callback used upon error
@param {Function} [callback] callback used when no error
Function for wraping callback to handle errors