Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

operator_catch

crates.io ci codecov license

On error, switch to a recovery observable.

See Also

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