actorx/error
Error handling operators for ActorX
These operators handle errors in observable sequences:
- retry: Resubscribe on error up to N times
- catch: Switch to fallback observable on error
Values
pub fn catch(
source: types.Observable(a),
handler: fn(String) -> types.Observable(a),
) -> types.Observable(a)
On error, switches to a fallback observable returned by the handler.
Also known as catch_error or on_error_resume_next.
Example
// On error, emit a default value
risky_observable
|> catch(fn(_error) { single(default_value) })
pub fn retry(
source: types.Observable(a),
max_retries: Int,
) -> types.Observable(a)
Resubscribes to the source observable when an error occurs, up to the specified number of retries.
Example
// Retry up to 3 times on error
flaky_observable
|> retry(3)