cdc: add fmt::formatter for exception types in data_dictionary.hh

before this change, we rely on the default-generated fmt::formatter
created from operator<<, but fmt v10 dropped the default-generated
formatter.

in this change, `fmt::formatter<>` is added for following classes for
backward compatibility with {fmt} < 10:

* `data_dictionary::no_such_keyspace`
* `data_dictionary::no_such_column_family`

Refs #13245

Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>
This commit is contained in:
Kefu Chai
2024-03-21 13:24:43 +08:00
parent a58be49abf
commit 6d77283941

View File

@@ -128,3 +128,20 @@ public:
};
}
#if FMT_VERSION < 100000
// fmt v10 introduced formatter for std::exception
template <>
struct fmt::formatter<data_dictionary::no_such_keyspace> : fmt::formatter<std::string_view> {
auto format(const data_dictionary::no_such_keyspace& e, fmt::format_context& ctx) const {
return fmt::format_to(ctx.out(), "{}", e.what());
}
};
template <>
struct fmt::formatter<data_dictionary::no_such_column_family> : fmt::formatter<std::string_view> {
auto format(const data_dictionary::no_such_column_family& e, fmt::format_context& ctx) const {
return fmt::format_to(ctx.out(), "{}", e.what());
}
};
#endif