Core/Misc: Remove StringFormat exception handling code from the header

This commit is contained in:
Shauren
2025-06-23 11:38:34 +02:00
parent be44801728
commit d62b412c92
6 changed files with 80 additions and 75 deletions

View File

@@ -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>;