Skip to content

Commit

Permalink
Added warning to documentation of dynamic_capture
Browse files Browse the repository at this point in the history
  • Loading branch information
zajo committed Dec 24, 2023
1 parent b856eac commit 736cbef
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions doc/leaf.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -3854,6 +3854,41 @@ When an object of type `dynamic_capture const &` is returned from a handler that

Under `BOOST_LEAF_CFG_CAPTURE=0`, `dynamic_capture` is unavailable.

[WARNING]
--
A `dynamic_capture` does not capture all error objects, only the ones that would have been discarded if not for the presence of a `dynamic_capture` handler. In the example below, the returned `result<void>` will capture the error object of type `E2` but not `e1`:
```
auto r = try_handle_some(
[]() -> leaf::result<void>
{
return leaf::new_error(E1{}, E2{});
},
[]( E1 e1, leaf::dynamic_capture const & cap ) -> leaf::result<void>
{
return cap;
});
```
Perhaps more surprising, this is true for the next example as well:
```
auto r = try_handle_some(
[]() -> leaf::result<void>
{
return try_handle_some(
[]() -> leaf::result<void>
{
return leaf::new_error(E1{}, E2{});
},
[]( leaf::dynamic_capture const & cap ) -> leaf::result<void>
{
return cap;
});
},
[]( E1 e1 )
{
});
```
--

See also: :: <<tutorial-async>>.

'''
Expand Down

0 comments on commit 736cbef

Please sign in to comment.