Skip to content

Commit 2342382

Browse files
committed
crimson/ertr: assert_all informs about error being handled that way
Signed-off-by: Matan Breizman <[email protected]> Signed-off-by: Radoslaw Zarzynski <[email protected]>
1 parent 3f41030 commit 2342382

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

src/crimson/common/errorator.h

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -964,7 +964,6 @@ struct errorator {
964964
return std::move(fut);
965965
}
966966

967-
// assert_all{ "TODO" };
968967
class assert_all {
969968
const char* const msg = nullptr;
970969
public:
@@ -975,14 +974,14 @@ struct errorator {
975974
assert_all() = default;
976975

977976
template <class ErrorT, EnableIf<ErrorT>...>
978-
no_touch_error_marker operator()(ErrorT&&) {
979-
static_assert(contains_once_v<std::decay_t<ErrorT>>,
977+
no_touch_error_marker operator()(ErrorT&& raw_error) {
978+
using decayed_t = std::decay_t<ErrorT>;
979+
static_assert(contains_once_v<decayed_t>,
980980
"discarding disallowed ErrorT");
981-
if (msg) {
982-
ceph_abort_msg(msg);
983-
} else {
984-
ceph_abort();
985-
}
981+
auto&& handler = decayed_t::error_t::handle([this] (auto&& error_v) {
982+
ceph_abort_msgf("%s: %s", msg ? msg : "", error_v.message().c_str());
983+
});
984+
std::invoke(std::move(handler), std::forward<ErrorT>(raw_error));
986985
return no_touch_error_marker{};
987986
}
988987
};
@@ -1346,15 +1345,15 @@ namespace ct_error {
13461345
: pre_assert(std::move(f)) {}
13471346

13481347
template <class ErrorT>
1349-
no_touch_error_marker operator()(ErrorT&&) {
1348+
no_touch_error_marker operator()(ErrorT&& raw_error) {
13501349
if (pre_assert) {
13511350
pre_assert();
13521351
}
1353-
if (msg) {
1354-
ceph_abort_msg(msg);
1355-
} else {
1356-
ceph_abort();
1357-
}
1352+
using decayed_t = std::decay_t<ErrorT>;
1353+
auto&& handler = decayed_t::error_t::handle([this] (auto&& error_v) {
1354+
ceph_abort_msgf("%s: %s", msg ? msg : "", error_v.message().c_str());
1355+
});
1356+
std::invoke(std::move(handler), std::forward<ErrorT>(raw_error));
13581357
return no_touch_error_marker{};
13591358
}
13601359
};

0 commit comments

Comments
 (0)