diff options
author | Shauren <shauren.trinity@gmail.com> | 2025-06-23 11:38:34 +0200 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2025-06-23 11:38:34 +0200 |
commit | d62b412c925ffa348b9586ebbf43adc15cb12462 (patch) | |
tree | bb9005ef1135e73821b3f1ad4db493e0646b8b8b /src/common/Utilities/StringFormat.cpp | |
parent | be448017289c3c8df2d6dc44fe93b16b91b02daf (diff) |
Core/Misc: Remove StringFormat exception handling code from the header
Diffstat (limited to 'src/common/Utilities/StringFormat.cpp')
-rw-r--r-- | src/common/Utilities/StringFormat.cpp | 24 |
1 files changed, 23 insertions, 1 deletions
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 <fmt/format.h> +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<char>& 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<int>; template struct TC_COMMON_API fmt::formatter<unsigned>; |