Permalink
Browse files

continue to run subtopics even if a parent topic has an error in it (f…

…ixes #231)
  • Loading branch information...
1 parent eb66421 commit a23a1c97325c87a1cdb34c6d5f54a14184ca5f6c @adamstallard adamstallard committed Apr 17, 2013
Showing with 27 additions and 6 deletions.
  1. +2 −0 .gitignore
  2. +10 −6 lib/vows/suite.js
  3. +15 −0 test/vows-error-test.js
View
@@ -2,4 +2,6 @@ node_modules
.idea
.nul
.hgignore
+.hgsubstate
+.hg
test/npm-debug.log
View
@@ -230,13 +230,17 @@ this.Suite.prototype = new(function () {
if (topic &&
ctx.name !== 'on' &&
(!topic._vowsEmitedEvents || !topic._vowsEmitedEvents.hasOwnProperty(ctx.event))) {
- topic.on(ctx.event, function (ctx) {
- return function (val) {
- return run(new(Context)(vow, ctx, env), lastTopic);
+ var runInnerContext = function(ctx){
+ return function(val){
+ return run(new (Context)(vow, ctx, env), lastTopic);
};
- }(ctx));
- } else {
- run(new(Context)(vow, ctx, env), lastTopic);
+ }(ctx);
+ topic.on(ctx.event, runInnerContext);
+ // Run an inner context if the outer context fails, too.
+ topic.on('error', runInnerContext);
+ }
+ else {
+ run(new (Context)(vow, ctx, env), lastTopic);
}
}
});
View
@@ -102,6 +102,21 @@ vows.describe('Error Handling').addBatch({
assert.equal(results.honored, 0);
}
}
+ },
+ "A topic with an error in it" : {
+ topic : function(){
+ throw('awesome');
+ },
+ "should error" : function(error, result){
+ assert.equal(error, 'awesome');
+ },
+ "containing a subtopic" : {
+ topic : function(){
+ return 52;
+ },
+ "should reach a vow in the subtopic" : function(){
+ }
+ }
}
}).export(module);

0 comments on commit a23a1c9

Please sign in to comment.