summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Rx/v2/examples/doxygen/blocking_observable.cpp3
-rw-r--r--Rx/v2/src/rxcpp/rx-observable.hpp10
2 files changed, 7 insertions, 6 deletions
diff --git a/Rx/v2/examples/doxygen/blocking_observable.cpp b/Rx/v2/examples/doxygen/blocking_observable.cpp
index ee94013..1e7dd56 100644
--- a/Rx/v2/examples/doxygen/blocking_observable.cpp
+++ b/Rx/v2/examples/doxygen/blocking_observable.cpp
@@ -25,8 +25,7 @@ SCENARIO("blocking first empty sample"){
SCENARIO("blocking first error sample"){
printf("//! [blocking first error sample]\n");
- auto values = rxcpp::observable<>::range(1, 3).
- concat(rxcpp::observable<>::error<int>(std::runtime_error("Error from source"))).
+ auto values = rxcpp::observable<>::error<int>(std::runtime_error("Error from source")).
as_blocking();
try {
auto first = values.first();
diff --git a/Rx/v2/src/rxcpp/rx-observable.hpp b/Rx/v2/src/rxcpp/rx-observable.hpp
index 8675820..cf2a381 100644
--- a/Rx/v2/src/rxcpp/rx-observable.hpp
+++ b/Rx/v2/src/rxcpp/rx-observable.hpp
@@ -305,8 +305,12 @@ public:
*/
T first() {
rxu::maybe<T> result;
+ rxu::maybe<std::exception_ptr> error;
composite_subscription cs;
- subscribe_with_rethrow(cs, [&](T v){result.reset(v); cs.unsubscribe();});
+ subscribe_with_rethrow(
+ cs,
+ [&](T v){result.reset(v); cs.unsubscribe();},
+ [&](std::exception_ptr){});
if (result.empty())
throw rxcpp::empty_error("first() requires a stream with at least one value");
return result.get();
@@ -332,9 +336,7 @@ public:
rxu::maybe<std::exception_ptr> error;
subscribe_with_rethrow(
[&](T v){result.reset(v);},
- [&](std::exception_ptr ep){error.reset(ep);});
- if (!error.empty())
- std::rethrow_exception(error.get());
+ [&](std::exception_ptr){});
if (result.empty())
throw rxcpp::empty_error("last() requires a stream with at least one value");
return result.get();