]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commit
crimson/errorator: helpers for tl::expected
authorRadoslaw Zarzynski <rzarzyns@redhat.com>
Mon, 19 Jan 2026 22:27:19 +0000 (22:27 +0000)
committerRadoslaw Zarzynski <rzarzyns@redhat.com>
Tue, 24 Mar 2026 16:06:24 +0000 (16:06 +0000)
commit33b7b7bca044aada1f79615f9ac1e92aa6fd4047
treeb82e4955b15f4769cecae8c36b26718f6afe979b
parent83a9a013a684f28ef2c21cd896ade5b3756b9b76
crimson/errorator: helpers for tl::expected

`ErrorHelper` is supposed to facilitate transformation of `std::error_code`
(and similar) into an immediately failed errorated `future` with extra error
checking.

The main idea is to let something like:

```cpp
my_ertr_t::future<my_value_t> foo() {
  // ...
  // `maybe_decoded` here is an instance of `tl::expected` carrying `std::error_code`
  // in its error part
  if (!maybe_decoded) {
    // `std::error_code` can convey errors `my_ertr_t` does not allow – in that case,
    // it would be helpful to get at least a run-time assert.
    return ErrorHelper<my_ertr_t>::from_error<my_value_t>(maybe_decoded.error());
  }
  // ...
}
```

Signed-off-by: Radoslaw Zarzynski <rzarzyns@redhat.com>
(cherry picked from commit a7ffc18eb40b9145fca5f064c4b3d097bffeb8d0)
src/crimson/common/errorator-utils.h