On Mon, Jan 21, 2019 at 6:14 PM Sorin Fetche via Boost < boost@lists.boost.org> wrote:
On Wed, Jan 16, 2019 at 11:51 AM Emil Dotchevski via Boost
wrote: LEAF is a C++11 error handling library for use in low-latency
environments.
- Can be used with or without exception handling.
Is it possible to have a common error handling logic for both error codes and exceptions? Something like:
leaf::result<T> function_that_may_throw(); ... leaf::handle_all( [i]() -> leaf::result<int> { LEAF_AUTO(r, leaf::exception_to_resultstd::exception([] { function_that_may_throw(); })); ... return 0; }, [](std::exception const &e) { // Handle exception(s) return 1; }, [](custom_error_code ec) { // Handle error code(s) return 2; })
The attached program shows that once leaf::exception_to_result() is used, only the exceptions reach the handlers in `handle_all`.
You found a bug, thank you. I had not tested exception_to_result with a
function that returns result<T>, and it incorrectly deduced its return type
as result