Browse Source

log.hpp: fix lack of return when FMT_EXCEPTIONS is disabled

When compiling with clang, the compiler warns about the lack of return
statement in the non-void function fmt::format.

This fixes it by returning a default error string.
pull/8153/head
Cyril SIX 7 months ago committed by Anders Jenbo
parent
commit
5fd8af76ee
  1. 10
      Source/utils/log.hpp

10
Source/utils/log.hpp

@ -52,13 +52,17 @@ std::string format(std::string_view fmt, Args &&...args)
}
FMT_CATCH(const fmt::format_error &e)
{
std::string error;
#if FMT_EXCEPTIONS
// e.what() is undefined if exceptions are disabled, so we wrap the whole block
// e.what() is undefined if exceptions are disabled, so we wrap it
// with an `FMT_EXCEPTIONS` check.
std::string error = StrCat("Format error, fmt: ", fmt, " error: ", e.what());
error = e.what();
#else
error = "unknown (FMT_EXCEPTIONS disabled)";
#endif
std::string fullError = StrCat("Format error, fmt: ", fmt, " error: ", error);
SDL_LogCritical(SDL_LOG_CATEGORY_APPLICATION, "%s", error.c_str());
app_fatal(error);
#endif
}
}

Loading…
Cancel
Save