2
0
mirror of https://github.com/boostorg/leaf.git synced 2026-02-22 15:32:24 +00:00

Improved diagnostic_details, able to access error objects from parent error handling scopes

This commit is contained in:
Emil Dotchevski
2026-02-10 15:07:46 -05:00
parent f3ac5509d4
commit 36a28472f3
9 changed files with 303 additions and 87 deletions

View File

@@ -128,5 +128,43 @@ int main()
BOOST_TEST_EQ(counter, 0);
} );
BOOST_TEST_EQ(counter, 0);
{
int r = leaf::try_handle_all(
[]() -> leaf::result<int>
{
return leaf::try_handle_some(
[]() -> leaf::result<int>
{
return leaf::new_error(info<1>{});
},
[]( leaf::diagnostic_details const & di ) -> leaf::result<int>
{
#if BOOST_LEAF_CFG_STD_STRING
std::ostringstream st;
st << di;
std::string s = st.str();
std::cout << s << std::endl;
if( BOOST_LEAF_CFG_DIAGNOSTICS )
if( BOOST_LEAF_CFG_CAPTURE )
BOOST_TEST_NE(s.find("info<1>"), s.npos);
else
BOOST_TEST_EQ(s.find("info<1>"), s.npos);
#endif
return di.error();
} );
},
[]( info<1> const & )
{
return 1;
},
[]
{
return 2;
} );
BOOST_TEST_EQ(r, 1);
}
BOOST_TEST_EQ(counter, 0);
return boost::report_errors();
}