aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/common/Utilities/StringFormat.h10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/common/Utilities/StringFormat.h b/src/common/Utilities/StringFormat.h
index dd990c637e2..ba0adacc888 100644
--- a/src/common/Utilities/StringFormat.h
+++ b/src/common/Utilities/StringFormat.h
@@ -26,7 +26,15 @@ namespace Trinity
template<typename Format, typename... Args>
inline std::string StringFormat(Format&& fmt, Args&&... args)
{
- return fmt::sprintf(std::forward<Format>(fmt), std::forward<Args>(args)...);
+ try
+ {
+ return fmt::sprintf(std::forward<Format>(fmt), std::forward<Args>(args)...);
+ }
+ catch (const fmt::FormatError& formatError)
+ {
+ std::string error = "An error occurred formatting string \"" + std::string(fmt) + "\" : " + std::string(formatError.what());
+ return error;
+ }
}
/// Returns true if the given char pointer is null.