1 #include "rxcpp/rx.hpp" 2 3 #include "rxcpp/rx-test.hpp" 4 #include "catch.hpp" 5 6 SCENARIO("error sample"){ 7 printf("//! [error sample]\n"); 8 auto values = rxcpp::observable<>::error<int>(std::runtime_error("Error from source")); 9 values. 10 subscribe( __anonfeb848390102(int v)11 [](int v){printf("OnNext: %d\n", v);}, __anonfeb848390202(rxcpp::util::error_ptr ep)12 [](rxcpp::util::error_ptr ep){ 13 printf("OnError: %s\n", rxcpp::util::what(ep).c_str()); 14 }, __anonfeb848390302()15 [](){printf("OnCompleted\n");}); 16 printf("//! [error sample]\n"); 17 } 18 19 SCENARIO("threaded error sample"){ 20 printf("//! [threaded error sample]\n"); 21 auto values = rxcpp::observable<>::error<int>(std::runtime_error("Error from source"), rxcpp::observe_on_event_loop()); 22 values. 23 as_blocking(). 24 subscribe( __anonfeb848390402(int v)25 [](int v){printf("OnNext: %d\n", v);}, __anonfeb848390502(rxcpp::util::error_ptr ep)26 [](rxcpp::util::error_ptr ep){ 27 printf("OnError: %s\n", rxcpp::util::what(ep).c_str()); 28 }, __anonfeb848390602()29 [](){printf("OnCompleted\n");}); 30 printf("//! [threaded error sample]\n"); 31 } 32