Permalink
Browse files

[dist minor] returns stream if callback is called

  • Loading branch information...
1 parent 2e52e19 commit 137ba95e7a25c7d571a9b78fe9b74416557cfa17 @dscape dscape committed May 14, 2012
Showing with 2 additions and 1 deletion.
  1. +1 −0 lib/errs.js
  2. +1 −1 package.json
View
@@ -168,6 +168,7 @@ exports.handle = function (error, callback, stream) {
if (typeof callback === 'function') {
callback(error);
+ if(stream) { return stream; }
}
if (typeof callback !== 'function' || stream) {
View
@@ -1,7 +1,7 @@
{
"name": "errs",
"description": "Simple error creation and passing utilities",
- "version": "0.2.1",
+ "version": "0.2.2",
"author": "Nodejitsu Inc. <info@nodejitsu.com>",
"maintainers": [
"indexzero <charlie@nodejitsu.com>",

3 comments on commit 137ba95

Owner

indexzero replied May 15, 2012

@dscape This broke the following test: https://github.com/flatiron/errs/blob/master/test/errs-test.js#L81-100

Are you sure this is what you wanted to do? Previously we would invoke the callback then check the stream:

See: https://github.com/flatiron/errs/blob/master/lib/errs.js#L174-178

//
// If there is no callback **or** there is a stream.
//
if (typeof callback !== 'function' || stream) {
  var emitter = stream || callback || new events.EventEmitter();
  process.nextTick(function () { emitter.emit('error', error); });
  return emitter;
}
Owner

indexzero replied May 15, 2012

I've reverted this for now. Do we want to have the behavior: "If a callback and a stream is provided then only invoke the callback"? It seems wrong to me that we would surpress the error on the stream.

Contributor

dscape replied May 15, 2012

I think this is wrong too. But often node core and request have this behavior.

Thanks for reverting, I'll check this out soon!

Please sign in to comment.