code: function(err, res) {
      if (_.isFunction(callback)) {
        try {
          res = callback(err, res);
          err = null;
        } catch(e) {
          err = e;
        }
      }
      if (err) {
        deferred.reject(err);
      } else {
        deferred.resolve(res);
      }
    }
docs: callback and promise resolution;