ReactivePlusPlus
One more implementation of ReactiveX approach in C++ with care about performance and templates in mind
 
Loading...
Searching...
No Matches
Error handling Operators

Error handling operators Operators that help to recover from error notifications from an Observable. More...

Functions

template<rpp::details::resume_callable ResumeCallable>
requires is_header_included<on_error_resume_next_tag, ResumeCallable>
auto observable::on_error_resume_next (ResumeCallable &&resume_callable) const &
 Recover from an on_error notification by continuing the sequence without error.
 

Detailed Description

Error handling operators Operators that help to recover from error notifications from an Observable.

See also
https://reactivex.io/documentation/operators.html#error

Function Documentation

◆ on_error_resume_next()

template<constraint::decayed_type Type, typename SpecificObservable >
template<rpp::details::resume_callable ResumeCallable>
requires is_header_included<on_error_resume_next_tag, ResumeCallable>
auto observable::on_error_resume_next ( ResumeCallable &&  resume_callable) const &
inline

Recover from an on_error notification by continuing the sequence without error.

The operator intercepts an on_error notification from the source Observable and, instead of passing it through to any observers, replaces it with some other item or sequence of items.

Warning
This operator potentially allows the resulting Observable to terminate normally or not to terminate at all.

Actually this operator just subscribes on observable calculated from callback when on_error from original observable obtained.

Parameters
resume_callableA callable that is given an error pointer and shall return an Observable.
Returns
new specific_observable with the on_error_resume_next operator as most recent operator.
Warning
#include <rpp/operators/on_error_resume_next.hpp>
Examples
rpp::source::error<int>(std::make_exception_ptr(std::runtime_error{""}))
.on_error_resume_next([](auto&&)
{
return rpp::observable::just(1, 2, 3);
})
.subscribe([&](int v)
{
std::cout << "-" << v;
},
[&](auto&&)
{
std::cout << "-x";
},
[&]()
{
std::cout << "-|" << std::endl;
});
// source: -x
// output: -1-2-3-|
Implementation details:
  • On subscribe
    • None
  • OnNext
    • Just forwards original on_next
  • OnError from original observable
    • Subscribes subscriber on observable obtained from callable
  • OnError from calculated observable
    • Just forwards original on_error
  • OnCompleted
    • Just forwards original on_completed
See also
https://reactivex.io/documentation/operators/on_error_resume_next.html