test/boost: print runtime_error using e.what()

before this change, we rely on the default-generated fmt::formatter
created from operator<<, but fmt v10 dropped the default-generated
formatter. but fortunately, fmt v10 brings the builtin
formatter for classes derived from `std::exception`. but before
switching to {fmt} v10, and after dropping `FMT_DEPRECATED_OSTREAM`
macro, we need to print out `std::runtime_error`. so far, we don't
have a shared place for formatter for `std::runtime_error`. so we
are addressing the needs on a case-by-case basis.

in this change, we just print it using `e.what()`. it's behavior
is identical to what we have now.

Refs #13245

Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>
This commit is contained in:
Kefu Chai
2024-03-27 13:14:23 +08:00
parent 04370dc8a4
commit d0ceb35e7e

View File

@@ -972,9 +972,9 @@ SEASTAR_THREAD_TEST_CASE(read_max_size) {
}
} catch (std::runtime_error& e) {
if (should_throw) {
testlog.trace("Exception thrown, as expected: {}", e);
testlog.trace("Exception thrown, as expected: {}", e.what());
} else {
BOOST_FAIL(fmt::format("Expected no exception, but caught: {}", e));
BOOST_FAIL(fmt::format("Expected no exception, but caught: {}", e.what()));
}
}
}
@@ -1044,7 +1044,7 @@ SEASTAR_THREAD_TEST_CASE(unpaged_mutation_read_global_limit) {
BOOST_REQUIRE(size != 0);
BOOST_FAIL("Expected exception, but none was thrown.");
} catch (std::runtime_error& e) {
testlog.trace("Exception thrown, as expected: {}", e);
testlog.trace("Exception thrown, as expected: {}", e.what());
}
}
}, std::move(cfg)).get();