June 2018
Intermediate to advanced
348 pages
8h 45m
English
An error occurrence breaks the sequence flow of a standard reactive Stream. The RxCpp library provides mechanisms to invoke actions on an error occurrence, also. Sometimes, however, users want to resume the sequence with a default option; that's what on_error_resume_next() does:
//------- OnError3.cpp #include "rxcpp/rx.hpp" int main() { //------- Create an Observable with appended error auto values = rxcpp::observable<>::range(1, 3). concat(rxcpp::observable<>:: error<int>(std::runtime_error("Error from producer! "))). //------- Resuming with another Stream on_error_resume_next([](std::exception_ptr ep) { printf("Resuming after: %sn", rxcpp::util::what(ep).c_str()); return rxcpp::observable<>::range(4,6); }); ...