diff options
Diffstat (limited to 'Rx/v2/examples')
-rw-r--r-- | Rx/v2/examples/doxygen/on_error_resume_next.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/Rx/v2/examples/doxygen/on_error_resume_next.cpp b/Rx/v2/examples/doxygen/on_error_resume_next.cpp new file mode 100644 index 0000000..0c9873b --- /dev/null +++ b/Rx/v2/examples/doxygen/on_error_resume_next.cpp @@ -0,0 +1,23 @@ +#include "rxcpp/rx.hpp" +namespace rxu=rxcpp::util; + +#include "rxcpp/rx-test.hpp" +#include "catch.hpp" + +SCENARIO("on_error_resume_next sample"){ + printf("//! [on_error_resume_next sample]\n"); + auto values = rxcpp::observable<>::range(1, 3). + concat(rxcpp::observable<>::error<int>(std::runtime_error("Error from source"))). + on_error_resume_next([](std::exception_ptr ep){ + printf("Resuming after: %s\n", rxu::what(ep).c_str()); + return rxcpp::observable<>::just(-1); + }); + values. + subscribe( + [](int v){printf("OnNext: %d\n", v);}, + [](std::exception_ptr ep){ + printf("OnError: %s\n", rxu::what(ep).c_str()); + }, + [](){printf("OnCompleted\n");}); + printf("//! [on_error_resume_next sample]\n"); +} |