Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Infinite loop with multiple catch()'s #28

Open
jfeldstein opened this Issue · 0 comments

1 participant

@jfeldstein

Should catch() not be used to catch errors after individual steps?

In my script, I have long Seq chains which perform multistep procedures, and I'd been using .catch() to respond to errors at multiple points in the chain. Turns out that when any error is encountered, the first catch in the chain is always the one that responds to it, even if execution has already passed that point. Afterwards, execution continues from that catch, often repeating chunks of the chain.

Seq = require('seq');

Seq()
.seq(function() {
  this(null, 'hi');
})
.catch(function(e){
  console.error("First catch", e);
})
.seq(function(){
  this('an error');
})
.seq(function(n){
  console.log("Should not run, proceed to catch.");
  this(null, n);
})
.catch(function(e){
  console.error("Second Catch", e);
})
.seq(function(n){
  console.log("Continued after second catch.");
  this(null, n);
})
@yasuoza yasuoza referenced this issue from a commit in yasuoza/node-seq
@yasuoza yasuoza Catch error at individual step. For issue #28 02c9c8b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.