From d62b412c925ffa348b9586ebbf43adc15cb12462 Mon Sep 17 00:00:00 2001 From: Shauren Date: Mon, 23 Jun 2025 11:38:34 +0200 Subject: Core/Misc: Remove StringFormat exception handling code from the header --- src/common/Utilities/StringFormat.cpp | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'src/common/Utilities/StringFormat.cpp') diff --git a/src/common/Utilities/StringFormat.cpp b/src/common/Utilities/StringFormat.cpp index 9550294fd64..acc1b4682e9 100644 --- a/src/common/Utilities/StringFormat.cpp +++ b/src/common/Utilities/StringFormat.cpp @@ -16,9 +16,31 @@ */ #include "StringFormat.h" -#include "Define.h" #include +namespace Trinity::Impl +{ +std::string StringVFormat(FormatStringView fmt, FormatArgs args) noexcept +try +{ + return fmt::vformat(fmt, args); +} +catch (std::exception const& formatError) +{ + return fmt::format(R"(An error occurred formatting string "{}" : {})", fmt, formatError.what()); +} + +void StringVFormatToImpl(fmt::detail::buffer& buffer, FormatStringView fmt, FormatArgs args) noexcept +try +{ + fmt::detail::vformat_to(buffer, fmt, args, {}); +} +catch (std::exception const& formatError) +{ + fmt::detail::vformat_to(buffer, FormatStringView(R"(An error occurred formatting string "{}" : {})"), MakeFormatArgs(fmt, formatError.what()), {}); +} +} + // explicit template instantiations template struct TC_COMMON_API fmt::formatter; template struct TC_COMMON_API fmt::formatter; -- cgit v1.2.3