Skip to content

Commit d2a748e

Browse files
committed
crimson/common/errorator: assert_failure to print error
Signed-off-by: Matan Breizman <[email protected]>
1 parent 7207975 commit d2a748e

File tree

1 file changed

+17
-21
lines changed

1 file changed

+17
-21
lines changed

src/crimson/common/errorator.h

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -220,15 +220,13 @@ struct unthrowable_wrapper : error_t<unthrowable_wrapper<ErrorT, ErrorV>> {
220220
assert_failure(Func&& f)
221221
: pre_assert(std::forward<Func>(f)) {}
222222

223-
no_touch_error_marker operator()(const unthrowable_wrapper&) {
224-
if (pre_assert) {
225-
pre_assert();
226-
}
227-
if (msg) {
228-
ceph_abort_msg(msg);
229-
} else {
230-
ceph_abort();
231-
}
223+
no_touch_error_marker operator()(const unthrowable_wrapper& raw_error) {
224+
handle([this] (auto&& error_v) {
225+
if (pre_assert) {
226+
pre_assert();
227+
}
228+
ceph_abort_msgf("%s: %s", msg ? msg : "", error_v.message().c_str());
229+
})(raw_error);
232230
return no_touch_error_marker{};
233231
}
234232
};
@@ -310,19 +308,17 @@ struct stateful_error_t : error_t<stateful_error_t<ErrorT>> {
310308
assert_failure(Func&& f)
311309
: pre_assert(std::forward<Func>(f)) {}
312310

313-
no_touch_error_marker operator()(stateful_error_t<ErrorT>&& e) {
314-
if (pre_assert) {
315-
try {
316-
std::rethrow_exception(e.ep);
317-
} catch (const ErrorT& err) {
318-
pre_assert(err);
311+
no_touch_error_marker operator()(stateful_error_t<ErrorT>&& raw_error) {
312+
handle([this] (auto&& error_v) {
313+
if (pre_assert) {
314+
try {
315+
std::rethrow_exception(e.ep);
316+
} catch (const ErrorT& err) {
317+
pre_assert(err);
318+
}
319319
}
320-
}
321-
if (msg) {
322-
ceph_abort_msg(msg);
323-
} else {
324-
ceph_abort();
325-
}
320+
ceph_abort_msgf("%s: %s", msg ? msg : "", error_v.message().c_str());
321+
})(std::move(raw_error));
326322
return no_touch_error_marker{};
327323
}
328324
};

0 commit comments

Comments
 (0)