Rethrows an error with more context when an error occurs during an iteration, i.e.
function* gen() {
yield 1;
throw new Error("test error");
}
const stream = new ArrayStream(gen, new Breaker()).collect();
// throws: Error occurred at item at index 1 in iterator: test error
Rethrows an error with more context when an error occurs during an operation, i.e.
const stream = new ArrayStream([1,2,3,4,5], new Breaker())
.map((x) => {
if (x === 3) {
throw new Error("test error");
}
return x;
})
.collect()
// throws: Error occurred while performing map on 3 at index 2 in iterator: test error
Error handler that breaks the execution of the pipeline on the first error. Compiling the data will return the data as is. This is similar to not having any error handling if you wish to do the error handling externally.
The Breaker handler is the default error handler for the
ArrayStream
andAsyncArrayStream
classes.