# Catch Error Operator

Rocket.catch_errorFunction
catch_error(selectorFn::F) where F

Creates a CatchErrorOperator, which catches errors on the observable to be handled by returning a new observable or throwing an error.

Arguments:

• selectorFn::F: a callable object that takes as arguments err, which is the error, and caught, which is the source observable, in case you'd like to "retry" that observable by returning it again. Whatever observable is returned by the selector will be used to continue the observable chain.

Producing

Stream of type <: Subscribable{L} where L refers to type of source stream

Examples

using Rocket

source = from(1:5) |> safe() |> map(Int, (d) -> d == 4 ? error(4) : d) |> catch_error((err, obs) -> of(1))

subscribe!(source, logger())
;

# output
[LogActor] Data: 1
[LogActor] Data: 2
[LogActor] Data: 3
[LogActor] Data: 1
[LogActor] Completed
source