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