aboutsummaryrefslogtreecommitdiff
path: root/src/common/Utilities/StringFormat.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/Utilities/StringFormat.cpp')
-rw-r--r--src/common/Utilities/StringFormat.cpp24
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>;