ResStream<S, F>.attempt constructor

ResStream<S, F>.attempt({
  1. required Stream<S> run(),
  2. required F handle(
    1. Object e
    ),
})

Wraps a stream of plain values, catching its errors as failures.

Each data event becomes a Success, and each error event a Failure holding handle(e), the exception and the stack trace. The stream carries on after an error, so sources that recover on their own aren't lost. If the factory throws, the stream emits one failure and closes. If handle throws, that error passes through untyped.

Implementation

ResStream.attempt({
  required Stream<S> Function() run,
  required F Function(Object e) handle,
}) : this._(t.ResultStream.attempt(run: run, handle: handle));