in include/unifex/let_error.hpp [100:128]
void set_error(ErrorValue e) noexcept {
UNIFEX_ASSERT(op_ != nullptr);
auto op = op_; // preserve pointer value.
using final_sender_t = callable_result_t<Func, ErrorValue>;
using final_op_t =
unifex::connect_result_t<final_sender_t, final_receiver<ErrorValue>>;
UNIFEX_TRY {
scope_guard destroyPredOp = [&]() noexcept {
unifex::deactivate_union_member(op->sourceOp_);
};
auto& err = op->error_.template construct<ErrorValue>((ErrorValue &&) e);
destroyPredOp.reset();
scope_guard destroyErr = [&]() noexcept {
op->error_.template destruct<ErrorValue>();
};
auto& finalOp =
unifex::activate_union_member_with<final_op_t>(op->finalOp_, [&] {
return unifex::connect(
std::move(op->func_)(err), final_receiver<ErrorValue>{op});
});
unifex::start(finalOp);
destroyErr.release();
}
UNIFEX_CATCH(...) {
unifex::set_error(std::move(op->receiver_), std::current_exception());
}
}