Reputation: 636
I'm essentially creating a transaction. A simplification would be described as follows:
1) Make a promise call. 2) If error and error.code === "ConditionalCheckFailedException", ignore the error and continue the stream with no changes. 3) If error, stop stream.
The following give me 1 and 3. I would like to continue on with the stream if I have a certain exception. Is that possible? ...
At the moment, I have:
//... stream that works to this point
.concatMap((item) => {
const insertions = Rx.Observable.fromPromise(AwsCall(item))
.catch(e => {
if (e.code === "ConditionalCheckFailedException") {
return item
} else {
throw e;
}
});
return insertions.map(() => item);
})
.concat // ... much the same
Upvotes: 0
Views: 154
Reputation: 1532
So catch
wants a function which delivers a new Observable.
Instead, use this:
//... stream that works to this point
.concatMap((item) => {
const insertions = Rx.Observable.fromPromise(AwsCall(item))
.catch(e => e.code === "ConditionalCheckFailedException"
? Rx.Observable.of(item)
: Rx.Observable.throw(e)
)
/* depending on what AwsCall returns this might not be necessary: */
.map(_ => item)
return insertions;
})
.concat // ... much the same
Source: http://reactivex.io/rxjs/class/es6/Observable.js~Observable.html#instance-method-catch
Upvotes: 1