From cee6397efb09fb584ae3d62ff6a4d14aeedc04fa Mon Sep 17 00:00:00 2001 From: Paul Ribault Date: Sun, 7 Dec 2025 12:30:07 +0100 Subject: [PATCH] Allow error handlers to be called directly with an exception --- CMakeLists.txt | 1 + examples/resource-loading/main.cpp | 8 +- include/recpp/rx/Completable.h | 9 +++ include/recpp/rx/Maybe.h | 9 +++ include/recpp/rx/Observable.h | 9 +++ include/recpp/rx/Single.h | 9 +++ include/recpp/rx/inl/Completable.inl | 8 ++ include/recpp/rx/inl/Maybe.inl | 9 +++ include/recpp/rx/inl/Observable.inl | 9 +++ include/recpp/rx/inl/Single.inl | 9 +++ .../recpp/subscribers/CompletableSubscriber.h | 10 +++ include/recpp/subscribers/MaybeSubscriber.h | 8 ++ .../recpp/subscribers/ObservableSubscriber.h | 8 ++ include/recpp/subscribers/SingleSubscriber.h | 8 ++ .../subscribers/inl/CompletableSubscriber.inl | 9 +++ .../recpp/subscribers/inl/MaybeSubscriber.inl | 9 +++ .../subscribers/inl/ObservableSubscriber.inl | 9 +++ .../subscribers/inl/SingleSubscriber.inl | 9 +++ rscpp | 2 +- tests/rx/Completable.cpp | 38 ++++----- tests/rx/Maybe.cpp | 52 ++++++------- tests/rx/Observable.cpp | 78 +++++++++---------- tests/rx/Single.cpp | 62 +++++++-------- 23 files changed, 262 insertions(+), 120 deletions(-) create mode 100644 include/recpp/subscribers/inl/CompletableSubscriber.inl diff --git a/CMakeLists.txt b/CMakeLists.txt index f089339..7c4911e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -93,6 +93,7 @@ set(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/include/recpp/subscribers/MaybeSubscriber.h ${CMAKE_CURRENT_SOURCE_DIR}/include/recpp/subscribers/ObservableSubscriber.h ${CMAKE_CURRENT_SOURCE_DIR}/include/recpp/subscribers/SingleSubscriber.h + ${CMAKE_CURRENT_SOURCE_DIR}/include/recpp/subscribers/inl/CompletableSubscriber.inl ${CMAKE_CURRENT_SOURCE_DIR}/include/recpp/subscribers/inl/DefaultSubscriber.inl ${CMAKE_CURRENT_SOURCE_DIR}/include/recpp/subscribers/inl/MaybeSubscriber.inl ${CMAKE_CURRENT_SOURCE_DIR}/include/recpp/subscribers/inl/ObservableSubscriber.inl diff --git a/examples/resource-loading/main.cpp b/examples/resource-loading/main.cpp index 31e4e16..c109839 100644 --- a/examples/resource-loading/main.cpp +++ b/examples/resource-loading/main.cpp @@ -61,7 +61,7 @@ Completable standardResourcesLoad(Context &context, const filesystem::path &path error_code error; const auto dirIterator = filesystem::directory_iterator(path, error); if (error) - return Completable::error(make_exception_ptr(runtime_error(error.message()))); + return Completable::error(runtime_error(error.message())); for (const auto &entry : dirIterator) { @@ -77,7 +77,7 @@ Completable standardResourcesLoad(Context &context, const filesystem::path &path if (!parseFromStream(builder, stream, &root, &errs)) { cout << errs << endl; - return Completable::error(make_exception_ptr(runtime_error(errs))); + return Completable::error(runtime_error(errs)); } } return Completable::complete(); @@ -93,7 +93,7 @@ Completable rxResourcesLoad(Context &context, const filesystem::path &path) const auto dirIterator = filesystem::directory_iterator(path, error); if (error) { - subscriber.onError(make_exception_ptr(runtime_error(error.message()))); + subscriber.onError(runtime_error(error.message())); return; } @@ -114,7 +114,7 @@ Completable rxResourcesLoad(Context &context, const filesystem::path &path) if (!parseFromStream(builder, stream, &root, &errs)) { cout << errs << endl; - return Completable::error(make_exception_ptr(runtime_error(errs))); + return Completable::error(runtime_error(errs)); } return Completable::complete(); }) diff --git a/include/recpp/rx/Completable.h b/include/recpp/rx/Completable.h index 2aa1edf..25b0980 100644 --- a/include/recpp/rx/Completable.h +++ b/include/recpp/rx/Completable.h @@ -87,6 +87,15 @@ namespace recpp::rx */ static Completable error(const std::exception_ptr &error); + /** + * @brief Construct a new {@link Completable} instance that will emit the given error when subscribed to. + * + * @param error The error to emit. + * @return The new {@link Completable} instance. + */ + template + static Completable error(E error); + /** * @brief Construct a new {@link Completable} instance that will never emit a signal when subscribed to. * diff --git a/include/recpp/rx/Maybe.h b/include/recpp/rx/Maybe.h index 6198932..ac06e03 100644 --- a/include/recpp/rx/Maybe.h +++ b/include/recpp/rx/Maybe.h @@ -96,6 +96,15 @@ namespace recpp::rx */ static Maybe error(const std::exception_ptr &error); + /** + * @brief Construct a new {@link Maybe} instance that will emit the given error when subscribed to. + * + * @param error The error to emit. + * @return The new {@link Maybe} instance. + */ + template + static Maybe error(E error); + /** * @brief Construct a new {@link Maybe} instance that will emit the given value when subscribed to. * diff --git a/include/recpp/rx/Observable.h b/include/recpp/rx/Observable.h index 37ff8b8..8affe83 100644 --- a/include/recpp/rx/Observable.h +++ b/include/recpp/rx/Observable.h @@ -96,6 +96,15 @@ namespace recpp::rx */ static Observable error(const std::exception_ptr &error); + /** + * @brief Construct a new {@link Observable} instance that will emit the given error when subscribed to. + * + * @param error The error to emit. + * @return The new {@link Observable} instance. + */ + template + static Observable error(E error); + /** * @brief Construct a new {@link Observable} instance that will emit the given value when subscribed to. * diff --git a/include/recpp/rx/Single.h b/include/recpp/rx/Single.h index 453f2f9..9abda44 100644 --- a/include/recpp/rx/Single.h +++ b/include/recpp/rx/Single.h @@ -89,6 +89,15 @@ namespace recpp::rx */ static Single error(const std::exception_ptr &error); + /** + * @brief Construct a new {@link Single} instance that will emit the given error when subscribed to. + * + * @param error The error to emit. + * @return The new {@link Single} instance. + */ + template + static Single error(E error); + /** * @brief Construct a new {@link Single} instance that will emit the given value when subscribed to. * diff --git a/include/recpp/rx/inl/Completable.inl b/include/recpp/rx/inl/Completable.inl index db86542..8450c0b 100644 --- a/include/recpp/rx/inl/Completable.inl +++ b/include/recpp/rx/inl/Completable.inl @@ -6,6 +6,14 @@ #include #include +#include + +template +recpp::rx::Completable recpp::rx::Completable::error(E error) +{ + return Completable::error(std::make_exception_ptr(error)); +} + template recpp::rx::Maybe recpp::rx::Completable::andThen(const recpp::rx::Maybe &maybe) { diff --git a/include/recpp/rx/inl/Maybe.inl b/include/recpp/rx/inl/Maybe.inl index 161c239..37defb1 100644 --- a/include/recpp/rx/inl/Maybe.inl +++ b/include/recpp/rx/inl/Maybe.inl @@ -19,6 +19,8 @@ #include #include +#include + template recpp::rx::Maybe recpp::rx::Maybe::create(const std::function &)> &method) { @@ -43,6 +45,13 @@ recpp::rx::Maybe recpp::rx::Maybe::error(const std::exception_ptr &error) return Maybe(std::make_shared>(error)); } +template +template +recpp::rx::Maybe recpp::rx::Maybe::error(E error) +{ + return Maybe::error(std::make_exception_ptr(error)); +} + template recpp::rx::Maybe recpp::rx::Maybe::just(const T &value) { diff --git a/include/recpp/rx/inl/Observable.inl b/include/recpp/rx/inl/Observable.inl index a68b628..8acf365 100644 --- a/include/recpp/rx/inl/Observable.inl +++ b/include/recpp/rx/inl/Observable.inl @@ -34,6 +34,8 @@ #include #include +#include + template recpp::rx::Observable recpp::rx::Observable::create(const std::function &)> &method) { @@ -58,6 +60,13 @@ recpp::rx::Observable recpp::rx::Observable::error(const std::exception_pt return Observable(std::make_shared>(error)); } +template +template +recpp::rx::Observable recpp::rx::Observable::error(E error) +{ + return Observable::error(std::make_exception_ptr(error)); +} + template recpp::rx::Observable recpp::rx::Observable::just(const T &value) { diff --git a/include/recpp/rx/inl/Single.inl b/include/recpp/rx/inl/Single.inl index 0cafc21..c5e98e2 100644 --- a/include/recpp/rx/inl/Single.inl +++ b/include/recpp/rx/inl/Single.inl @@ -19,6 +19,8 @@ #include #include +#include + template recpp::rx::Single recpp::rx::Single::create(const std::function &)> &method) { @@ -37,6 +39,13 @@ recpp::rx::Single recpp::rx::Single::error(const std::exception_ptr &error return Single(std::make_shared>(error)); } +template +template +recpp::rx::Single recpp::rx::Single::error(E error) +{ + return Single::error(std::make_exception_ptr(error)); +} + template recpp::rx::Single recpp::rx::Single::just(const T &value) { diff --git a/include/recpp/subscribers/CompletableSubscriber.h b/include/recpp/subscribers/CompletableSubscriber.h index d0e78ca..ffa2f16 100644 --- a/include/recpp/subscribers/CompletableSubscriber.h +++ b/include/recpp/subscribers/CompletableSubscriber.h @@ -28,6 +28,14 @@ namespace recpp::subscribers */ void onError(const std::exception_ptr &error); + /** + * @brief Emits the given error to the {@link rscpp::Subscriber} if it has not already been emitted. + * + * @param error The error to emit. + */ + template + void onError(E error); + /** * @brief Emits a completion signal to the {@link rscpp::Subscriber} if it has not already been emitted. */ @@ -38,3 +46,5 @@ namespace recpp::subscribers bool m_ended = false; }; } // namespace recpp::subscribers + +#include diff --git a/include/recpp/subscribers/MaybeSubscriber.h b/include/recpp/subscribers/MaybeSubscriber.h index 0406b12..eb51635 100644 --- a/include/recpp/subscribers/MaybeSubscriber.h +++ b/include/recpp/subscribers/MaybeSubscriber.h @@ -37,6 +37,14 @@ namespace recpp::subscribers */ void onError(const std::exception_ptr &error); + /** + * @brief Emits the given error to the {@link rscpp::Subscriber} if it has not already been emitted. + * + * @param error The error to emit. + */ + template + void onError(E error); + /** * @brief Emits a completion signal to the {@link rscpp::Subscriber} if it has not already been emitted. */ diff --git a/include/recpp/subscribers/ObservableSubscriber.h b/include/recpp/subscribers/ObservableSubscriber.h index 9369cdf..9af8348 100644 --- a/include/recpp/subscribers/ObservableSubscriber.h +++ b/include/recpp/subscribers/ObservableSubscriber.h @@ -37,6 +37,14 @@ namespace recpp::subscribers */ void onError(const std::exception_ptr &error); + /** + * @brief Emits the given error to the {@link rscpp::Subscriber} if it has not already been emitted. + * + * @param error The error to emit. + */ + template + void onError(E error); + /** * @brief Emits a completion signal to the {@link rscpp::Subscriber} if it has not already been emitted. */ diff --git a/include/recpp/subscribers/SingleSubscriber.h b/include/recpp/subscribers/SingleSubscriber.h index 0671f77..97d36b0 100644 --- a/include/recpp/subscribers/SingleSubscriber.h +++ b/include/recpp/subscribers/SingleSubscriber.h @@ -37,6 +37,14 @@ namespace recpp::subscribers */ void onError(const std::exception_ptr &error); + /** + * @brief Emits the given error to the {@link rscpp::Subscriber} if it has not already been emitted. + * + * @param error The error to emit. + */ + template + void onError(E error); + private: rscpp::Subscriber m_subscriber; bool m_ended = false; diff --git a/include/recpp/subscribers/inl/CompletableSubscriber.inl b/include/recpp/subscribers/inl/CompletableSubscriber.inl new file mode 100644 index 0000000..051071d --- /dev/null +++ b/include/recpp/subscribers/inl/CompletableSubscriber.inl @@ -0,0 +1,9 @@ +#pragma once + +#include + +template +void recpp::subscribers::CompletableSubscriber::onError(E error) +{ + onError(std::make_exception_ptr(error)); +} diff --git a/include/recpp/subscribers/inl/MaybeSubscriber.inl b/include/recpp/subscribers/inl/MaybeSubscriber.inl index dd42cf0..75a9d85 100644 --- a/include/recpp/subscribers/inl/MaybeSubscriber.inl +++ b/include/recpp/subscribers/inl/MaybeSubscriber.inl @@ -1,5 +1,7 @@ #pragma once +#include + template recpp::subscribers::MaybeSubscriber::MaybeSubscriber(const rscpp::Subscriber &subscriber) : m_subscriber(subscriber) @@ -27,6 +29,13 @@ void recpp::subscribers::MaybeSubscriber::onError(const std::exception_ptr &e } } +template +template +void recpp::subscribers::MaybeSubscriber::onError(E error) +{ + onError(std::make_exception_ptr(error)); +} + template void recpp::subscribers::MaybeSubscriber::onComplete() { diff --git a/include/recpp/subscribers/inl/ObservableSubscriber.inl b/include/recpp/subscribers/inl/ObservableSubscriber.inl index fc90de4..ee87be6 100644 --- a/include/recpp/subscribers/inl/ObservableSubscriber.inl +++ b/include/recpp/subscribers/inl/ObservableSubscriber.inl @@ -1,5 +1,7 @@ #pragma once +#include + template recpp::subscribers::ObservableSubscriber::ObservableSubscriber(const rscpp::Subscriber &subscriber) : m_subscriber(subscriber) @@ -23,6 +25,13 @@ void recpp::subscribers::ObservableSubscriber::onError(const std::exception_p } } +template +template +void recpp::subscribers::ObservableSubscriber::onError(E error) +{ + onError(std::make_exception_ptr(error)); +} + template void recpp::subscribers::ObservableSubscriber::onComplete() { diff --git a/include/recpp/subscribers/inl/SingleSubscriber.inl b/include/recpp/subscribers/inl/SingleSubscriber.inl index 6459081..4731e30 100644 --- a/include/recpp/subscribers/inl/SingleSubscriber.inl +++ b/include/recpp/subscribers/inl/SingleSubscriber.inl @@ -1,5 +1,7 @@ #pragma once +#include + template recpp::subscribers::SingleSubscriber::SingleSubscriber(const rscpp::Subscriber &subscriber) : m_subscriber(subscriber) @@ -26,3 +28,10 @@ void recpp::subscribers::SingleSubscriber::onError(const std::exception_ptr & m_subscriber.onError(error); } } + +template +template +void recpp::subscribers::SingleSubscriber::onError(E error) +{ + onError(std::make_exception_ptr(error)); +} diff --git a/rscpp b/rscpp index 1916282..0bc5b7a 160000 --- a/rscpp +++ b/rscpp @@ -1 +1 @@ -Subproject commit 1916282abb47f85f25577c8b95097a7621e7fffd +Subproject commit 0bc5b7a338b0a44df09e2a259ac324ab5846acad diff --git a/tests/rx/Completable.cpp b/tests/rx/Completable.cpp index 76e72f4..e75cb93 100644 --- a/tests/rx/Completable.cpp +++ b/tests/rx/Completable.cpp @@ -83,7 +83,7 @@ class CompletableCreate : public testing::Test return Completable::create( [](auto &subscriber) { - subscriber.onError(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))); + subscriber.onError(runtime_error(runtimeErrorMessage.data())); }); } static Completable errorTwice() @@ -91,8 +91,8 @@ class CompletableCreate : public testing::Test return Completable::create( [](auto &subscriber) { - subscriber.onError(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))); - subscriber.onError(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))); + subscriber.onError(runtime_error(runtimeErrorMessage.data())); + subscriber.onError(runtime_error(runtimeErrorMessage.data())); }); } static Completable errorAfterComplete() @@ -101,7 +101,7 @@ class CompletableCreate : public testing::Test [](auto &subscriber) { subscriber.onComplete(); - subscriber.onError(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))); + subscriber.onError(runtime_error(runtimeErrorMessage.data())); }); } static Completable completeAfterError() @@ -110,7 +110,7 @@ class CompletableCreate : public testing::Test [](auto &subscriber) { subscriber.onComplete(); - subscriber.onError(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))); + subscriber.onError(runtime_error(runtimeErrorMessage.data())); }); } }; @@ -260,7 +260,7 @@ TEST_F(CompletableDefer, checkOnErrorIsEmited) Completable::defer( []() { - return Completable::error(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))); + return Completable::error(runtime_error(runtimeErrorMessage.data())); }) // .subscribe([]() {}, [&gotError](const auto &exception) @@ -285,7 +285,7 @@ class CompletableError : public testing::Test TEST_F(CompletableError, checkOnCompleteIsNotEmited) { - Completable::error(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))) // + Completable::error(runtime_error(runtimeErrorMessage.data())) // .subscribe( []() { @@ -296,7 +296,7 @@ TEST_F(CompletableError, checkOnCompleteIsNotEmited) TEST_F(CompletableError, checkOnErrorIsEmited) { bool gotError = false; - Completable::error(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))) // + Completable::error(runtime_error(runtimeErrorMessage.data())) // .subscribe([]() {}, [&gotError](const auto &exception) { @@ -351,7 +351,7 @@ class CompletableMerge : public testing::Test Observable completableList = Observable::create( [](auto &subscriber) { - subscriber.onNext(Completable::error(make_exception_ptr(runtime_error(runtimeErrorMessage.data())))); + subscriber.onNext(Completable::error(runtime_error(runtimeErrorMessage.data()))); subscriber.onComplete(); }); return Completable::merge(completableList); @@ -432,7 +432,7 @@ TEST_F(CompletableDoOnComplete, checkOnCompleteIsEmited) TEST_F(CompletableDoOnComplete, checkOnCompleteIsNotEmitedOnError) { - Completable::error(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))) // + Completable::error(runtime_error(runtimeErrorMessage.data())) // .doOnComplete( []() { @@ -448,7 +448,7 @@ class CompletableDoOnError : public testing::Test TEST_F(CompletableDoOnError, checkOnErrorIsEmited) { bool gotError = false; - Completable::error(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))) // + Completable::error(runtime_error(runtimeErrorMessage.data())) // .doOnError( [&gotError](const auto &exception) { @@ -499,7 +499,7 @@ TEST_F(CompletableDoOnTerminate, checkOnTerminateIsEmitedOnComplete) TEST_F(CompletableDoOnTerminate, checkOnTerminateIsEmitedOnError) { bool terminated = false; - Completable::error(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))) // + Completable::error(runtime_error(runtimeErrorMessage.data())) // .doOnTerminate( [&terminated]() { @@ -531,7 +531,7 @@ TEST_F(CompletableTap, checkOnCompleteIsEmited) TEST_F(CompletableTap, checkOnCompleteIsNotEmitedOnError) { - Completable::error(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))) // + Completable::error(runtime_error(runtimeErrorMessage.data())) // .tap( []() { @@ -544,7 +544,7 @@ TEST_F(CompletableTap, checkOnCompleteIsNotEmitedOnError) TEST_F(CompletableTap, checkOnErrorIsEmited) { bool gotError = false; - Completable::error(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))) // + Completable::error(runtime_error(runtimeErrorMessage.data())) // .tap([]() {}, [&gotError](const auto &exception) { @@ -612,7 +612,7 @@ TEST_F(CompletableObserveOn, checkDoOnCompleteCalledOnWorkerThread) TEST_F(CompletableObserveOn, checkDoOnErrorCalledOnWorkerThread) { bool gotError = false; - Completable::error(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))) // + Completable::error(runtime_error(runtimeErrorMessage.data())) // .observeOn(*m_worker) .doOnError( [this, &gotError](const auto &exception) @@ -672,7 +672,7 @@ TEST_F(CompletableSubscribeOn, checkDoOnCompleteCalledOnWorkerThread) TEST_F(CompletableSubscribeOn, checkDoOnErrorCalledOnWorkerThread) { bool gotError = false; - Completable::error(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))) // + Completable::error(runtime_error(runtimeErrorMessage.data())) // .subscribeOn(*m_worker) .doOnError( [this, &gotError](const auto &exception) @@ -760,7 +760,7 @@ TEST_F(CompletableAndThen, checkNextObservableIsCalledOnComplete) TEST_F(CompletableAndThen, checkAndThenIsNotCalledOnError) { bool deferCalled = false; - Completable::error(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))) // + Completable::error(runtime_error(runtimeErrorMessage.data())) // .andThen(Completable::defer( [&deferCalled]() { @@ -808,7 +808,7 @@ TEST_F(CompletableDelay, checkOnErrorDelay) [&start]() { start = recpp::async::Scheduler::Clock::now(); - return Completable::error(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))); + return Completable::error(runtime_error(runtimeErrorMessage.data())); }) // .delay(*m_eventLoop, delayDuration, true) .subscribe([]() {}, @@ -832,7 +832,7 @@ TEST_F(CompletableDelay, checkNoErrorDelayMode) [&start]() { start = recpp::async::Scheduler::Clock::now(); - return Completable::error(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))); + return Completable::error(runtime_error(runtimeErrorMessage.data())); }) // .delay(*m_eventLoop, delayDuration, false) .subscribe([]() {}, diff --git a/tests/rx/Maybe.cpp b/tests/rx/Maybe.cpp index 90c1810..e119d71 100644 --- a/tests/rx/Maybe.cpp +++ b/tests/rx/Maybe.cpp @@ -73,7 +73,7 @@ class MaybeCreate : public testing::Test return Maybe::create( [](auto &subscriber) { - subscriber.onError(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))); + subscriber.onError(runtime_error(runtimeErrorMessage.data())); }); } static Maybe valueAfterError() @@ -81,7 +81,7 @@ class MaybeCreate : public testing::Test return Maybe::create( [](auto &subscriber) { - subscriber.onError(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))); + subscriber.onError(runtime_error(runtimeErrorMessage.data())); subscriber.onNext(42); }); } @@ -90,8 +90,8 @@ class MaybeCreate : public testing::Test return Maybe::create( [](auto &subscriber) { - subscriber.onError(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))); - subscriber.onError(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))); + subscriber.onError(runtime_error(runtimeErrorMessage.data())); + subscriber.onError(runtime_error(runtimeErrorMessage.data())); }); } static Maybe completeAfterError() @@ -99,7 +99,7 @@ class MaybeCreate : public testing::Test return Maybe::create( [](auto &subscriber) { - subscriber.onError(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))); + subscriber.onError(runtime_error(runtimeErrorMessage.data())); subscriber.onComplete(); }); } @@ -226,7 +226,7 @@ class MaybeDefer : public testing::Test return Maybe::defer( []() { - return Maybe::error(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))); + return Maybe::error(runtime_error(runtimeErrorMessage.data())); }); } }; @@ -336,7 +336,7 @@ class MaybeError : public testing::Test protected: static Maybe errored() { - return Maybe::error(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))); + return Maybe::error(runtime_error(runtimeErrorMessage.data())); } }; @@ -496,7 +496,7 @@ TEST_F(MaybeMap, checkNoErrorIsEmited) TEST_F(MaybeMap, checkErrorsAreForwarded) { bool gotError = false; - Maybe::error(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))) // + Maybe::error(runtime_error(runtimeErrorMessage.data())) // .map(÷ByTen) .subscribe([](const auto) {}, [&gotError](const auto &exception) @@ -517,7 +517,7 @@ TEST_F(MaybeMap, checkErrorsAreForwarded) TEST_F(MaybeMap, checkDoNotCompleteOnError) { - Maybe::error(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))) // + Maybe::error(runtime_error(runtimeErrorMessage.data())) // .map(÷ByTen) .subscribe([](const auto) {}, [](const auto &) {}, []() @@ -575,7 +575,7 @@ TEST_F(MaybeFlatMap, checkNoErrorIsEmited) TEST_F(MaybeFlatMap, checkErrorsAreForwarded) { bool gotError = false; - Maybe::error(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))) // + Maybe::error(runtime_error(runtimeErrorMessage.data())) // .flatMap( [](const auto) { @@ -599,7 +599,7 @@ TEST_F(MaybeFlatMap, checkErrorsAreForwarded) TEST_F(MaybeFlatMap, checkDoNotCompleteOnError) { - Maybe::error(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))) // + Maybe::error(runtime_error(runtimeErrorMessage.data())) // .flatMap( [](const auto) { @@ -619,7 +619,7 @@ TEST_F(MaybeFlatMap, checkCanEmitErrors) .flatMap( [](const auto) { - return Maybe::error(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))); + return Maybe::error(runtime_error(runtimeErrorMessage.data())); }) .subscribe([](const auto) {}, [&gotError](const auto &exception) @@ -668,7 +668,7 @@ TEST_F(MaybeIgnoreElement, checkNoErrorIsEmited) TEST_F(MaybeIgnoreElement, checkErrorsAreForwarded) { bool gotError = false; - Maybe::error(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))) // + Maybe::error(runtime_error(runtimeErrorMessage.data())) // .ignoreElement() .subscribe([]() {}, [&gotError](const auto &exception) @@ -688,7 +688,7 @@ TEST_F(MaybeIgnoreElement, checkErrorsAreForwarded) TEST_F(MaybeIgnoreElement, checkDoNotCompleteOnError) { - Maybe::error(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))) // + Maybe::error(runtime_error(runtimeErrorMessage.data())) // .ignoreElement() .subscribe( []() @@ -717,7 +717,7 @@ TEST_F(MaybeDoOnComplete, checkDoOnCompleteIsCalledOnce) TEST_F(MaybeDoOnComplete, checkDoOnCompleteIsNotCalledOnError) { - Maybe::error(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))) // + Maybe::error(runtime_error(runtimeErrorMessage.data())) // .doOnComplete( []() { @@ -744,7 +744,7 @@ TEST_F(MaybeDoOnError, checkDoOnErrorIsNotCalledWhenNoErrorIsEmited) TEST_F(MaybeDoOnError, checkDoOnErrorIsCalledOnError) { bool gotError = false; - Maybe::error(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))) // + Maybe::error(runtime_error(runtimeErrorMessage.data())) // .doOnError( [&gotError](const auto &exception) { @@ -779,7 +779,7 @@ TEST_F(MaybeDoOnNext, checkDoOnNextIsCalledForEachValue) TEST_F(MaybeDoOnNext, checkDoOnNextIsNotCalledInCaseOfAnError) { - Maybe::error(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))) // + Maybe::error(runtime_error(runtimeErrorMessage.data())) // .doOnNext( [](const auto value) { @@ -808,7 +808,7 @@ TEST_F(MaybeDoOnTerminate, checkDoOnTerminateIsCalledAfterComplete) TEST_F(MaybeDoOnTerminate, checkDoOnTerminateIsCalledOnError) { bool terminated = false; - Maybe::error(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))) // + Maybe::error(runtime_error(runtimeErrorMessage.data())) // .doOnTerminate( [&terminated]() { @@ -838,7 +838,7 @@ TEST_F(MaybeTap, checkTapDoOnCompleteIsCalledOnce) TEST_F(MaybeTap, checkTapDoOnCompleteIsNotCalledOnError) { - Maybe::error(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))) // + Maybe::error(runtime_error(runtimeErrorMessage.data())) // .tap([](const auto) {}, [](const auto &) {}, []() { @@ -862,7 +862,7 @@ TEST_F(MaybeTap, checkTapDoOnErrorIsNotCalledWhenNoErrorIsEmited) TEST_F(MaybeTap, checkTapDoOnErrorIsCalledOnError) { bool gotError = false; - Maybe::error(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))) // + Maybe::error(runtime_error(runtimeErrorMessage.data())) // .tap([](const auto) {}, [&gotError](const auto &exception) { @@ -895,7 +895,7 @@ TEST_F(MaybeTap, checkTapDoOnNextIsCalled) TEST_F(MaybeTap, checkTapDoOnNextIsNotCalledInCaseOfAnError) { - Maybe::error(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))) // + Maybe::error(runtime_error(runtimeErrorMessage.data())) // .tap( [](const auto value) { @@ -944,7 +944,7 @@ TEST_F(MaybeObserveOn, checkDoOnNextCalledOnWorkerThread) TEST_F(MaybeObserveOn, checkDoOnErrorCalledOnWorkerThread) { bool doOnErrorCalled = false; - Maybe::error(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))) // + Maybe::error(runtime_error(runtimeErrorMessage.data())) // .observeOn(*m_worker) .doOnError( [this, &doOnErrorCalled](const auto &exception) @@ -1021,7 +1021,7 @@ TEST_F(MaybeSubscribeOn, checkDoOnNextCalledOnWorkerThread) TEST_F(MaybeSubscribeOn, checkDoOnErrorCalledOnWorkerThread) { bool doOnErrorCalled = false; - Maybe::error(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))) // + Maybe::error(runtime_error(runtimeErrorMessage.data())) // .subscribeOn(*m_worker) .doOnError( [this, &doOnErrorCalled](const auto &exception) @@ -1094,7 +1094,7 @@ TEST_F(MaybeDelay, checkOnErrorDelay) [&start]() { start = recpp::async::Scheduler::Clock::now(); - return Maybe::error(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))); + return Maybe::error(runtime_error(runtimeErrorMessage.data())); }) // .delay(*m_eventLoop, delayDuration, true) .subscribe([](const auto) {}, @@ -1118,7 +1118,7 @@ TEST_F(MaybeDelay, checkNoErrorDelayMode) [&start]() { start = recpp::async::Scheduler::Clock::now(); - return Maybe::error(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))); + return Maybe::error(runtime_error(runtimeErrorMessage.data())); }) // .delay(*m_eventLoop, delayDuration, false) .subscribe([](const auto) {}, @@ -1192,7 +1192,7 @@ TEST_F(MaybeSwitchIfEmpty, checkDefaultValueIsEmitedIfEmpty) TEST_F(MaybeSwitchIfEmpty, checkErrorsAreForwarded) { bool gotError = false; - Maybe::error(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))) // + Maybe::error(runtime_error(runtimeErrorMessage.data())) // .switchIfEmpty(otherValue) .subscribe([](const auto) {}, [&gotError](const auto &exception) diff --git a/tests/rx/Observable.cpp b/tests/rx/Observable.cpp index afa3718..9d019a7 100644 --- a/tests/rx/Observable.cpp +++ b/tests/rx/Observable.cpp @@ -92,7 +92,7 @@ class ObservableCreate : public testing::Test return Observable::create( [](auto &subscriber) { - subscriber.onError(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))); + subscriber.onError(runtime_error(runtimeErrorMessage.data())); }); } static Observable valueAfterError() @@ -100,7 +100,7 @@ class ObservableCreate : public testing::Test return Observable::create( [](auto &subscriber) { - subscriber.onError(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))); + subscriber.onError(runtime_error(runtimeErrorMessage.data())); subscriber.onNext(42); }); } @@ -109,8 +109,8 @@ class ObservableCreate : public testing::Test return Observable::create( [](auto &subscriber) { - subscriber.onError(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))); - subscriber.onError(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))); + subscriber.onError(runtime_error(runtimeErrorMessage.data())); + subscriber.onError(runtime_error(runtimeErrorMessage.data())); }); } static Observable completeAfterError() @@ -118,7 +118,7 @@ class ObservableCreate : public testing::Test return Observable::create( [](auto &subscriber) { - subscriber.onError(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))); + subscriber.onError(runtime_error(runtimeErrorMessage.data())); subscriber.onComplete(); }); } @@ -244,7 +244,7 @@ class ObservableDefer : public testing::Test return Observable::defer( []() { - return Observable::error(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))); + return Observable::error(runtime_error(runtimeErrorMessage.data())); }); } }; @@ -353,7 +353,7 @@ class ObservableError : public testing::Test protected: static Observable errored() { - return Observable::error(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))); + return Observable::error(runtime_error(runtimeErrorMessage.data())); } }; @@ -549,7 +549,7 @@ class ObservableMerge : public testing::Test [](auto &subscriber) { subscriber.onNext(Observable::range(defaultValues)); - subscriber.onNext(Observable::error(make_exception_ptr(runtime_error(runtimeErrorMessage.data())))); + subscriber.onNext(Observable::error(runtime_error(runtimeErrorMessage.data()))); subscriber.onNext(Observable::range(defaultValues)); subscriber.onComplete(); }); @@ -700,7 +700,7 @@ TEST_F(ObservableFilter, checkNoErrorIsEmited) TEST_F(ObservableFilter, checkErrorsAreForwarded) { bool gotError = false; - Observable::error(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))) // + Observable::error(runtime_error(runtimeErrorMessage.data())) // .filter(&isOdd) .subscribe([](const auto) {}, [&gotError](const auto &exception) @@ -720,7 +720,7 @@ TEST_F(ObservableFilter, checkErrorsAreForwarded) TEST_F(ObservableFilter, checkDoNotCompleteOnError) { - Observable::error(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))) // + Observable::error(runtime_error(runtimeErrorMessage.data())) // .filter(&isOdd) .subscribe([](const auto) {}, [](const auto &) {}, []() @@ -760,7 +760,7 @@ TEST_F(ObservableIgnoreElements, checkNoErrorIsEmited) TEST_F(ObservableIgnoreElements, checkErrorsAreForwarded) { bool gotError = false; - Observable::error(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))) // + Observable::error(runtime_error(runtimeErrorMessage.data())) // .ignoreElements() .subscribe([]() {}, [&gotError](const auto &exception) @@ -780,7 +780,7 @@ TEST_F(ObservableIgnoreElements, checkErrorsAreForwarded) TEST_F(ObservableIgnoreElements, checkDoNotCompleteOnError) { - Observable::error(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))) // + Observable::error(runtime_error(runtimeErrorMessage.data())) // .ignoreElements() .subscribe( []() @@ -828,7 +828,7 @@ TEST_F(ObservableMap, checkNoErrorIsEmited) TEST_F(ObservableMap, checkErrorsAreForwarded) { bool gotError = false; - Observable::error(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))) // + Observable::error(runtime_error(runtimeErrorMessage.data())) // .map(÷ByTen) .subscribe([](const auto) {}, [&gotError](const auto &exception) @@ -849,7 +849,7 @@ TEST_F(ObservableMap, checkErrorsAreForwarded) TEST_F(ObservableMap, checkDoNotCompleteOnError) { - Observable::error(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))) // + Observable::error(runtime_error(runtimeErrorMessage.data())) // .map(÷ByTen) .subscribe([](const auto) {}, [](const auto &) {}, []() @@ -912,7 +912,7 @@ TEST_F(ObservableFlatMap, checkNoErrorIsEmited) TEST_F(ObservableFlatMap, checkErrorsAreForwarded) { bool gotError = false; - Observable::error(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))) // + Observable::error(runtime_error(runtimeErrorMessage.data())) // .flatMap( [](const auto) { @@ -936,7 +936,7 @@ TEST_F(ObservableFlatMap, checkErrorsAreForwarded) TEST_F(ObservableFlatMap, checkDoNotCompleteOnError) { - Observable::error(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))) // + Observable::error(runtime_error(runtimeErrorMessage.data())) // .flatMap( [](const auto) { @@ -956,7 +956,7 @@ TEST_F(ObservableFlatMap, checkCanEmitErrors) .flatMap( [](const auto) { - return Observable::error(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))); + return Observable::error(runtime_error(runtimeErrorMessage.data())); }) .subscribe([](const auto) {}, [&gotError](const auto &exception) @@ -994,7 +994,7 @@ TEST_F(ObservableDoOnComplete, checkDoOnCompleteIsCalledOnce) TEST_F(ObservableDoOnComplete, checkDoOnCompleteIsNotCalledOnError) { - Observable::error(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))) // + Observable::error(runtime_error(runtimeErrorMessage.data())) // .doOnComplete( []() { @@ -1021,7 +1021,7 @@ TEST_F(ObservableDoOnError, checkDoOnErrorIsNotCalledWhenNoErrorIsEmited) TEST_F(ObservableDoOnError, checkDoOnErrorIsCalledOnError) { bool gotError = false; - Observable::error(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))) // + Observable::error(runtime_error(runtimeErrorMessage.data())) // .doOnError( [&gotError](const auto &exception) { @@ -1064,7 +1064,7 @@ TEST_F(ObservableDoOnNext, checkDoOnNextIsCalledForEachValue) TEST_F(ObservableDoOnNext, checkDoOnNextIsNotCalledInCaseOfAnError) { - Observable::error(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))) // + Observable::error(runtime_error(runtimeErrorMessage.data())) // .doOnNext( [](const auto value) { @@ -1093,7 +1093,7 @@ TEST_F(ObservableDoOnTerminate, checkDoOnTerminateIsCalledAfterComplete) TEST_F(ObservableDoOnTerminate, checkDoOnTerminateIsCalledOnError) { bool terminated = false; - Observable::error(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))) // + Observable::error(runtime_error(runtimeErrorMessage.data())) // .doOnTerminate( [&terminated]() { @@ -1123,7 +1123,7 @@ TEST_F(ObservableTap, checkTapDoOnCompleteIsCalledOnce) TEST_F(ObservableTap, checkTapDoOnCompleteIsNotCalledOnError) { - Observable::error(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))) // + Observable::error(runtime_error(runtimeErrorMessage.data())) // .tap([](const auto) {}, [](const auto &) {}, []() { @@ -1147,7 +1147,7 @@ TEST_F(ObservableTap, checkTapDoOnErrorIsNotCalledWhenNoErrorIsEmited) TEST_F(ObservableTap, checkTapDoOnErrorIsCalledOnError) { bool gotError = false; - Observable::error(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))) // + Observable::error(runtime_error(runtimeErrorMessage.data())) // .tap([](const auto) {}, [&gotError](const auto &exception) { @@ -1188,7 +1188,7 @@ TEST_F(ObservableTap, checkTapDoOnNextIsCalledForEachValue) TEST_F(ObservableTap, checkTapDoOnNextIsNotCalledInCaseOfAnError) { - Observable::error(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))) // + Observable::error(runtime_error(runtimeErrorMessage.data())) // .tap( [](const auto value) { @@ -1237,7 +1237,7 @@ TEST_F(ObservableObserveOn, checkDoOnNextCalledOnWorkerThread) TEST_F(ObservableObserveOn, checkDoOnErrorCalledOnWorkerThread) { bool doOnErrorCalled = false; - Observable::error(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))) // + Observable::error(runtime_error(runtimeErrorMessage.data())) // .observeOn(*m_worker) .doOnError( [this, &doOnErrorCalled](const auto &exception) @@ -1314,7 +1314,7 @@ TEST_F(ObservableSubscribeOn, checkDoOnNextCalledOnWorkerThread) TEST_F(ObservableSubscribeOn, checkDoOnErrorCalledOnWorkerThread) { bool doOnErrorCalled = false; - Observable::error(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))) // + Observable::error(runtime_error(runtimeErrorMessage.data())) // .subscribeOn(*m_worker) .doOnError( [this, &doOnErrorCalled](const auto &exception) @@ -1387,7 +1387,7 @@ TEST_F(ObservableDelay, checkOnErrorDelay) [&start]() { start = recpp::async::Scheduler::Clock::now(); - return Observable::error(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))); + return Observable::error(runtime_error(runtimeErrorMessage.data())); }) // .delay(*m_eventLoop, delayDuration, true) .subscribe([](const auto) {}, @@ -1411,7 +1411,7 @@ TEST_F(ObservableDelay, checkNoErrorDelayMode) [&start]() { start = recpp::async::Scheduler::Clock::now(); - return Observable::error(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))); + return Observable::error(runtime_error(runtimeErrorMessage.data())); }) // .delay(*m_eventLoop, delayDuration, false) .subscribe([](const auto) {}, @@ -1485,7 +1485,7 @@ TEST_F(ObservableDefaultIfEmpty, checkDefaultValueIsEmitedIfEmpty) TEST_F(ObservableDefaultIfEmpty, checkErrorsAreForwarded) { bool gotError = false; - Observable::error(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))) // + Observable::error(runtime_error(runtimeErrorMessage.data())) // .defaultIfEmpty(otherValue) .subscribe([](const auto) {}, [&gotError](const auto &exception) @@ -1538,7 +1538,7 @@ TEST_F(ObservableAllOf, checkCanReturnFalse) TEST_F(ObservableAllOf, checkErrorsAreForwarded) { bool gotError = false; - Observable::error(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))) // + Observable::error(runtime_error(runtimeErrorMessage.data())) // .allOf(&isEven) .subscribe([](const auto) {}, [&gotError](const auto &exception) @@ -1591,7 +1591,7 @@ TEST_F(ObservableAnyOf, checkCanReturnFalse) TEST_F(ObservableAnyOf, checkErrorsAreForwarded) { bool gotError = false; - Observable::error(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))) // + Observable::error(runtime_error(runtimeErrorMessage.data())) // .anyOf(&isEven) .subscribe([](const auto) {}, [&gotError](const auto &exception) @@ -1644,7 +1644,7 @@ TEST_F(ObservableNoneOf, checkCanReturnFalse) TEST_F(ObservableNoneOf, checkErrorsAreForwarded) { bool gotError = false; - Observable::error(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))) // + Observable::error(runtime_error(runtimeErrorMessage.data())) // .noneOf(&isEven) .subscribe([](const auto) {}, [&gotError](const auto &exception) @@ -1725,7 +1725,7 @@ TEST_F(ObservableReduce, checkWithOperationAndInitValue) TEST_F(ObservableReduce, checkErrorsAreForwarded) { bool gotError = false; - Observable::error(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))) // + Observable::error(runtime_error(runtimeErrorMessage.data())) // .reduce() .subscribe([](const auto) {}, [&gotError](const auto &exception) @@ -1778,7 +1778,7 @@ TEST_F(ObservableMax, checkWithComparator) TEST_F(ObservableMax, checkErrorsAreForwarded) { bool gotError = false; - Observable::error(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))) // + Observable::error(runtime_error(runtimeErrorMessage.data())) // .max() .subscribe([](const auto) {}, [&gotError](const auto &exception) @@ -1831,7 +1831,7 @@ TEST_F(ObservableMin, checkWithComparator) TEST_F(ObservableMin, checkErrorsAreForwarded) { bool gotError = false; - Observable::error(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))) // + Observable::error(runtime_error(runtimeErrorMessage.data())) // .min() .subscribe([](const auto) {}, [&gotError](const auto &exception) @@ -1870,7 +1870,7 @@ TEST_F(ObservableCount, checkFindsCorrectCount) TEST_F(ObservableCount, checkErrorsAreForwarded) { bool gotError = false; - Observable::error(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))) // + Observable::error(runtime_error(runtimeErrorMessage.data())) // .count() .subscribe([](const auto) {}, [&gotError](const auto &exception) @@ -1927,7 +1927,7 @@ TEST_F(ObservableElementAt, checkIsEmptyForOutOfRangeIndex) TEST_F(ObservableElementAt, checkErrorsAreForwarded) { bool gotError = false; - Observable::error(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))) // + Observable::error(runtime_error(runtimeErrorMessage.data())) // .elementAt(1) .subscribe([](const auto) {}, [&gotError](const auto &exception) @@ -1984,7 +1984,7 @@ TEST_F(ObservableFirst, checkIsEmptyForEmptyObservable) TEST_F(ObservableFirst, checkErrorsAreForwarded) { bool gotError = false; - Observable::error(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))) // + Observable::error(runtime_error(runtimeErrorMessage.data())) // .first() .subscribe([](const auto) {}, [&gotError](const auto &exception) @@ -2041,7 +2041,7 @@ TEST_F(ObservableLast, checkIsEmptyForEmptyObservable) TEST_F(ObservableLast, checkErrorsAreForwarded) { bool gotError = false; - Observable::error(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))) // + Observable::error(runtime_error(runtimeErrorMessage.data())) // .first() .subscribe([](const auto) {}, [&gotError](const auto &exception) diff --git a/tests/rx/Single.cpp b/tests/rx/Single.cpp index 3c61e6d..2850f76 100644 --- a/tests/rx/Single.cpp +++ b/tests/rx/Single.cpp @@ -58,7 +58,7 @@ class SingleCreate : public testing::Test return Single::create( [](auto &subscriber) { - subscriber.onError(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))); + subscriber.onError(runtime_error(runtimeErrorMessage.data())); }); } static Single twoErrors() @@ -66,8 +66,8 @@ class SingleCreate : public testing::Test return Single::create( [](auto &subscriber) { - subscriber.onError(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))); - subscriber.onError(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))); + subscriber.onError(runtime_error(runtimeErrorMessage.data())); + subscriber.onError(runtime_error(runtimeErrorMessage.data())); }); } static Single errorAfterValue() @@ -76,7 +76,7 @@ class SingleCreate : public testing::Test [](auto &subscriber) { subscriber.onNext(defaultValue); - subscriber.onError(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))); + subscriber.onError(runtime_error(runtimeErrorMessage.data())); }); } static Single valueAfterError() @@ -84,7 +84,7 @@ class SingleCreate : public testing::Test return Single::create( [](auto &subscriber) { - subscriber.onError(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))); + subscriber.onError(runtime_error(runtimeErrorMessage.data())); subscriber.onNext(defaultValue); }); } @@ -205,7 +205,7 @@ class SingleDefer : public testing::Test return Single::defer( []() { - return Single::error(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))); + return Single::error(runtime_error(runtimeErrorMessage.data())); }); } }; @@ -248,7 +248,7 @@ class SingleError : public testing::Test protected: static Single errored() { - return Single::error(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))); + return Single::error(runtime_error(runtimeErrorMessage.data())); } }; @@ -384,7 +384,7 @@ TEST_F(SingleMap, checkNoErrorIsEmited) TEST_F(SingleMap, checkErrorsAreForwarded) { bool gotError = false; - Single::error(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))) // + Single::error(runtime_error(runtimeErrorMessage.data())) // .map(÷ByTen) .subscribe([](const auto) {}, [&gotError](const auto &exception) @@ -404,7 +404,7 @@ TEST_F(SingleMap, checkErrorsAreForwarded) TEST_F(SingleMap, checkDoNotEmitValueOnError) { - Single::error(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))) // + Single::error(runtime_error(runtimeErrorMessage.data())) // .map(÷ByTen) .subscribe( [](const auto) @@ -453,7 +453,7 @@ TEST_F(SingleFlatMap, checkNoErrorIsEmited) TEST_F(SingleFlatMap, checkErrorsAreForwarded) { bool gotError = false; - Single::error(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))) // + Single::error(runtime_error(runtimeErrorMessage.data())) // .flatMap( [](const auto) { @@ -477,7 +477,7 @@ TEST_F(SingleFlatMap, checkErrorsAreForwarded) TEST_F(SingleFlatMap, checkDoNotEmitValueOnError) { - Single::error(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))) // + Single::error(runtime_error(runtimeErrorMessage.data())) // .flatMap( [](const auto) { @@ -497,7 +497,7 @@ TEST_F(SingleFlatMap, checkCanEmitErrors) .flatMap( [](const auto) { - return Single::error(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))); + return Single::error(runtime_error(runtimeErrorMessage.data())); }) .subscribe([](const auto) {}, [&gotError](const auto &exception) @@ -554,7 +554,7 @@ TEST_F(SingleFlatMapCompletable, checkNoErrorIsEmited) TEST_F(SingleFlatMapCompletable, checkErrorsAreForwarded) { bool gotError = false; - Single::error(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))) // + Single::error(runtime_error(runtimeErrorMessage.data())) // .flatMapCompletable( [](int) { @@ -582,7 +582,7 @@ TEST_F(SingleFlatMapCompletable, checkDoNotCompleteOnError) .flatMapCompletable( [](int) { - return Completable::error(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))); + return Completable::error(runtime_error(runtimeErrorMessage.data())); }) .subscribe( []() @@ -651,7 +651,7 @@ TEST_F(SingleFlatMapMaybe, checkNoErrorIsEmitedWithoutValue) TEST_F(SingleFlatMapMaybe, checkErrorsAreForwarded) { bool gotError = false; - Single::error(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))) // + Single::error(runtime_error(runtimeErrorMessage.data())) // .flatMapMaybe( [](const auto) { @@ -675,7 +675,7 @@ TEST_F(SingleFlatMapMaybe, checkErrorsAreForwarded) TEST_F(SingleFlatMapMaybe, checkDoNotEmitValueOnError) { - Single::error(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))) // + Single::error(runtime_error(runtimeErrorMessage.data())) // .flatMapMaybe( [](const auto) { @@ -695,7 +695,7 @@ TEST_F(SingleFlatMapMaybe, checkCanEmitErrors) .flatMapMaybe( [](const auto) { - return Maybe::error(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))); + return Maybe::error(runtime_error(runtimeErrorMessage.data())); }) .subscribe([](const auto) {}, [&gotError](const auto &exception) @@ -755,7 +755,7 @@ TEST_F(SingleFlatMapObservable, checkNoErrorIsEmited) TEST_F(SingleFlatMapObservable, checkErrorsAreForwarded) { bool gotError = false; - Single::error(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))) // + Single::error(runtime_error(runtimeErrorMessage.data())) // .flatMapObservable( [](const auto) { @@ -779,7 +779,7 @@ TEST_F(SingleFlatMapObservable, checkErrorsAreForwarded) TEST_F(SingleFlatMapObservable, checkDoNotEmitValueOnError) { - Single::error(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))) // + Single::error(runtime_error(runtimeErrorMessage.data())) // .flatMapObservable( [](const auto) { @@ -799,7 +799,7 @@ TEST_F(SingleFlatMapObservable, checkCanEmitErrors) .flatMapObservable( [](const auto) { - return Observable::error(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))); + return Observable::error(runtime_error(runtimeErrorMessage.data())); }) .subscribe([](const auto) {}, [&gotError](const auto &exception) @@ -848,7 +848,7 @@ TEST_F(SingleIgnoreElement, checkNoErrorIsEmited) TEST_F(SingleIgnoreElement, checkErrorsAreForwarded) { bool gotError = false; - Single::error(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))) // + Single::error(runtime_error(runtimeErrorMessage.data())) // .ignoreElement() .subscribe([]() {}, [&gotError](const auto &exception) @@ -868,7 +868,7 @@ TEST_F(SingleIgnoreElement, checkErrorsAreForwarded) TEST_F(SingleIgnoreElement, checkDoNotCompleteOnError) { - Single::error(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))) // + Single::error(runtime_error(runtimeErrorMessage.data())) // .ignoreElement() .subscribe( []() @@ -895,7 +895,7 @@ TEST_F(SingleDoOnError, checkDoOnErrorIsNotCalledWhenNoErrorIsEmited) TEST_F(SingleDoOnError, checkDoOnErrorIsCalledOnError) { bool gotError = false; - Single::error(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))) // + Single::error(runtime_error(runtimeErrorMessage.data())) // .doOnError( [&gotError](const auto &exception) { @@ -933,7 +933,7 @@ TEST_F(SingleDoOnSuccess, checkDoOnSuccessIsCalled) TEST_F(SingleDoOnSuccess, checkDoOnSuccessIsNotCalledInCaseOfAnError) { - Single::error(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))) // + Single::error(runtime_error(runtimeErrorMessage.data())) // .doOnSuccess( [](const auto value) { @@ -962,7 +962,7 @@ TEST_F(SingleDoOnTerminate, checkDoOnTerminateIsCalledAfterComplete) TEST_F(SingleDoOnTerminate, checkDoOnTerminateIsCalledOnError) { bool terminated = false; - Single::error(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))) // + Single::error(runtime_error(runtimeErrorMessage.data())) // .doOnTerminate( [&terminated]() { @@ -990,7 +990,7 @@ TEST_F(SingleTap, checkTapDoOnErrorIsNotCalledWhenNoErrorIsEmited) TEST_F(SingleTap, checkTapDoOnErrorIsCalledOnError) { bool gotError = false; - Single::error(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))) // + Single::error(runtime_error(runtimeErrorMessage.data())) // .tap([](const auto) {}, [&gotError](const auto &exception) { @@ -1025,7 +1025,7 @@ TEST_F(SingleTap, checkTapDoOnNextIsCalled) TEST_F(SingleTap, checkTapDoOnNextIsNotCalledInCaseOfAnError) { - Single::error(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))) // + Single::error(runtime_error(runtimeErrorMessage.data())) // .tap( [](const auto) { @@ -1074,7 +1074,7 @@ TEST_F(SingleObserveOn, checkDoOnSuccessCalledOnWorkerThread) TEST_F(SingleObserveOn, checkDoOnErrorCalledOnWorkerThread) { bool doOnErrorCalled = false; - Single::error(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))) // + Single::error(runtime_error(runtimeErrorMessage.data())) // .observeOn(*m_worker) .doOnError( [this, &doOnErrorCalled](const auto &exception) @@ -1135,7 +1135,7 @@ TEST_F(SingleSubscribeOn, checkDoOnSuccessCalledOnWorkerThread) TEST_F(SingleSubscribeOn, checkDoOnErrorCalledOnWorkerThread) { bool doOnErrorCalled = false; - Single::error(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))) // + Single::error(runtime_error(runtimeErrorMessage.data())) // .subscribeOn(*m_worker) .doOnError( [this, &doOnErrorCalled](const auto &exception) @@ -1192,7 +1192,7 @@ TEST_F(SingleDelay, checkOnErrorDelay) [&start]() { start = recpp::async::Scheduler::Clock::now(); - return Single::error(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))); + return Single::error(runtime_error(runtimeErrorMessage.data())); }) // .delay(*m_eventLoop, delayDuration, true) .subscribe([](const auto) {}, @@ -1216,7 +1216,7 @@ TEST_F(SingleDelay, checkNoErrorDelayMode) [&start]() { start = recpp::async::Scheduler::Clock::now(); - return Single::error(make_exception_ptr(runtime_error(runtimeErrorMessage.data()))); + return Single::error(runtime_error(runtimeErrorMessage.data())); }) // .delay(*m_eventLoop, delayDuration, false) .subscribe([](const auto) {},