aboutsummaryrefslogtreecommitdiff
path: root/src/common/Utilities/StringFormat.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/Utilities/StringFormat.h')
-rw-r--r--src/common/Utilities/StringFormat.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/common/Utilities/StringFormat.h b/src/common/Utilities/StringFormat.h
index 7c136185f4a..b2248aff6f1 100644
--- a/src/common/Utilities/StringFormat.h
+++ b/src/common/Utilities/StringFormat.h
@@ -39,6 +39,19 @@ namespace Trinity
}
}
+ template<typename OutputIt, typename... Args>
+ inline OutputIt StringFormatTo(OutputIt out, FormatString<Args...> fmt, Args&&... args)
+ {
+ try
+ {
+ return fmt::format_to(out, fmt, std::forward<Args>(args)...);
+ }
+ catch (std::exception const& formatError)
+ {
+ return fmt::format_to(out, "An error occurred formatting string \"{}\" : {}", fmt, formatError.what());
+ }
+ }
+
/// Returns true if the given char pointer is null.
inline bool IsFormatEmptyOrNull(char const* fmt)
{