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_error_boundary

crates.io ci codecov license

Enforce Never as the error type to guard pipelines at compile time.

See Also

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