Skip to Content
C++ Reactive Programming
book

C++ Reactive Programming

by Praseed Pai, Peter Abraham
June 2018
Intermediate to advanced
348 pages
8h 45m
English
Packt Publishing
Content preview from C++ Reactive Programming

Resuming when an error occurs

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); }); ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Functional Programming in C++

Functional Programming in C++

Ivan Cukic

Publisher Resources

ISBN: 9781788629775Supplemental Content