operator_catch
On error, switch to a recovery observable.
See Also
- RetryOperator - Resubscribe on error up to the configured retry count.
- IntoResultOperator -
Capture next/error signals as
Resultvalues. - LiftResultOperator -
Split
Resultvalues into next and error signals. - ErrorBoundaryOperator -
Enforce
Neveras the error type to guard pipelines at compile time.
Example
cargo run -p rx_core --example operator_catch_example
#![allow(unused)]
fn main() {
let _s = concat((
(1..=3).into_observable().map_never(),
throw("error").map_never(),
))
.map(|i| i * 10)
.catch(|_error| IteratorObservable::new(90..=92))
.subscribe(PrintObserver::new("catch"));
}
Output:
catch - next: 10
catch - next: 20
catch - next: 30
catch - next: 90
catch - next: 91
catch - next: 92
catch - completed
catch - unsubscribed