remove uses of std::source_location

This commit is contained in:
HJfod 2024-04-14 18:04:01 +03:00
parent 3fbda5748e
commit 53b081e77b
2 changed files with 8 additions and 21 deletions
loader
include/Geode/utils
src/utils

View file

@ -2,7 +2,6 @@
#include "../DefaultInclude.hpp"
#include "../loader/Log.hpp"
#include <source_location>
namespace geode {
class Mod;
@ -27,19 +26,14 @@ namespace geode::utils {
namespace detail {
// This needs to do stuff with `Mod*` which is not included in the file
GEODE_DLL std::string fmtTerminateError(const char* reason, Mod* mod, std::source_location loc);
GEODE_DLL std::string fmtTerminateError(const char* reason, Mod* mod);
}
template <class = void>
[[noreturn]]
void terminate(
std::string const& reason,
Mod* mod = getMod(),
std::source_location loc = std::source_location::current(),
size_t platformCode = GEODE_TERMINATE_EXCEPTION_CODE
) {
void terminate(std::string const& reason, Mod* mod = getMod(), size_t platformCode = GEODE_TERMINATE_EXCEPTION_CODE) {
// Add the error to the logfile
log::error("{}", detail::fmtTerminateError(reason.c_str(), mod, loc));
log::error("{}", detail::fmtTerminateError(reason.c_str(), mod));
#ifdef GEODE_IS_WINDOWS
// If a debugger is attached, start debugging
@ -63,11 +57,7 @@ namespace geode::utils {
template <class = void>
[[noreturn]]
void unreachable(
std::string const& reason = "Unspecified",
Mod* mod = getMod(),
std::source_location loc = std::source_location::current()
) {
terminate(reason, mod, loc, GEODE_UNREACHABLE_EXCEPTION_CODE);
void unreachable(std::string const& reason = "Unspecified", Mod* mod = getMod()) {
terminate(reason, mod, GEODE_UNREACHABLE_EXCEPTION_CODE);
}
}

View file

@ -3,12 +3,9 @@
using namespace geode::prelude;
std::string geode::utils::detail::fmtTerminateError(const char* reason, Mod* mod, std::source_location loc) {
std::string geode::utils::detail::fmtTerminateError(const char* reason, Mod* mod) {
return fmt::format(
"The mod '{}' by {} has deliberately asked the game to crash.\n"
"Reason: {}\n"
"Source: {}::{}():{}:{}",
mod->getID(), mod->getDeveloper(), reason,
loc.file_name(), loc.function_name(), loc.line(), loc.column()
"The mod '{}' by {} has deliberately asked the game to crash.\nReason: {}",
mod->getID(), mod->getDeveloper(), reason
);
}