operator_error_boundary
Enforce Never as the error type to guard pipelines at compile time.
See Also
- CatchOperator - On error, switch to a recovery observable.
- 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.
Example
cargo run -p rx_core --example operator_error_boundary_example
use rx_core::prelude::*;
/// The [IdentityOperator] does nothing. The only purpose it has
/// is to define inputs for a [CompositeOperator]: an [Operator] that made out
/// of other [Operator]s without having to use a [Pipe] which would require a
/// source [Observable]
fn main() {
let _s = (1..=5)
.into_observable()
.map(|i| i * 2)
.error_boundary()
.subscribe(PrintObserver::new("error_boundary_operator (composite)"));
// This cannot compile as relative to the `error_boundary` operator,
// upstreams error type is not `Never`
// let _s2 = throw("error".to_string())
// .map(|i| i)
// .error_boundary()
// .subscribe(PrintObserver::new("error_boundary_operator (composite)"));
let _s3 = throw("error".to_string())
.map(|i| i)
.into_result()
.error_boundary()
.subscribe(PrintObserver::new("error_boundary_operator (composite)"));
}
error_boundary_operator (composite) - next: 2
error_boundary_operator (composite) - next: 4
error_boundary_operator (composite) - next: 6
error_boundary_operator (composite) - next: 8
error_boundary_operator (composite) - next: 10
error_boundary_operator (composite) - completed
error_boundary_operator (composite) - unsubscribed
error_boundary_operator (composite) - next: Err("error")
error_boundary_operator (composite) - unsubscribed