summaryrefslogtreecommitdiff
path: root/Rx
diff options
context:
space:
mode:
authorValery Kopylov <v-valkop@microsoft.com>2015-06-09 17:04:08 +0300
committerValery Kopylov <v-valkop@microsoft.com>2015-06-09 17:04:08 +0300
commit4af4c2edc3c9e6e8f66bb3e61f4b3653eeae0f07 (patch)
treec4991723593dd30307e504b1c78c8199ebf32230 /Rx
parent2482b20a4a2d631b61002497af8ce72aacc842a2 (diff)
downloadRxCpp-4af4c2edc3c9e6e8f66bb3e61f4b3653eeae0f07.tar.gz
Blocking count() returns 0 if reduce throws an exception
Diffstat (limited to 'Rx')
-rw-r--r--Rx/v2/src/rxcpp/rx-observable.hpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/Rx/v2/src/rxcpp/rx-observable.hpp b/Rx/v2/src/rxcpp/rx-observable.hpp
index cf2a381..5a292f9 100644
--- a/Rx/v2/src/rxcpp/rx-observable.hpp
+++ b/Rx/v2/src/rxcpp/rx-observable.hpp
@@ -355,7 +355,11 @@ public:
\snippet output.txt blocking count error sample
*/
int count() const {
- return source.count().as_blocking().last();
+ int result;
+ on_exception(
+ [&](){result = source.count().as_blocking().last(); return true;},
+ [&](std::exception_ptr){result = 0;});
+ return result;
}
/*! Return the sum of all items emitted by this blocking_observable, or throw an std::runtime_error exception if it emits no items.