Error handling with batches
- Dominant language
- JavaScript
- Stars
- 3.4k
- Forks
- 145
- PR merge metrics
- No merged PRs in 30d
Description
Is there a technique that I can use to be able to return errors from a batch operation?
As an example, assume that I have to write records in batches of 3, but every write of odd entries results in an error. Before I am done, I want to log errors and remove them from the stream, while successful writes continue on.
``` js
h( [1, 2, 3, 4, 5, 6, 7, 8, 9] )
.map( preProcess )
.batch( 3 )
.doto( writeRecords ) // odd records result in error
.sequence() // would prefer a partition for errors and success
.errors( writeErrors )
.each( h.log );
```
I cannot indicate an error using the `throw` clause, since I am processing records in batch. Should I invoke `writeRecords` using a map and return some error object that can be filtered for errors, or is there a better technique available now for branching or partitioning a stream?
Contributor guide
Assessment
This issue has not been assessed yet.