Skip to content

Commit

Permalink
Allow arguments to flow through to callbacks in error conditions.
Browse files Browse the repository at this point in the history
https://gist.github.com/1152218  Topic callbacks should receive all
arguments passed in error situations.  Currently only the first argument
is passed to the callback function regardless of how many arguments are
sent.
  • Loading branch information
bentaber authored and indexzero committed Aug 21, 2011
1 parent 3b9acac commit 0108f1f
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/vows.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ function addVow(vow) {

}).on("error", function (err) {
if (vow.callback.length >= 2 || !batch.suite.options.error) {
runTest([err], this.ctx);
runTest(arguments, this.ctx);
} else {
output('errored', { type: 'promise', error: err.stack || err.message || JSON.stringify(err) });
}
Expand Down
2 changes: 1 addition & 1 deletion lib/vows/context.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ this.Context = function (vow, ctx, env) {
if (typeof(e) === 'boolean' && args.length === 0) {
that.emitter.emit.call(that.emitter, 'success', e);
} else {
if (e) { that.emitter.emit.call(that.emitter, 'error', e) }
if (e) { that.emitter.emit.apply(that.emitter, ['error', e].concat(args)) }
else { that.emitter.emit.apply(that.emitter, ['success'].concat(args)) }
}
};
Expand Down
2 changes: 1 addition & 1 deletion lib/vows/extras.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ this.prepare = function (obj, targets) {
args.push(function (err /* [, data] */) {
var args = Array.prototype.slice.call(arguments, 1);

if (err) { ee.emit('error', err) }
if (err) { ee.emit.apply(ee, ['error', err].concat(args)) }
else { ee.emit.apply(ee, ['success'].concat(args)) }
});
fun.apply(obj, args);
Expand Down

0 comments on commit 0108f1f

Please sign in to comment.