From 61b882b2a6dbe27b581662860da1361d986d136d Mon Sep 17 00:00:00 2001 From: Nekotekina Date: Thu, 10 Dec 2020 12:42:02 +0300 Subject: [PATCH] Always print system error code on 'throwing' errors. Print system error code in src_loc fmt. Error code may be irrelevant though. --- Utilities/StrFmt.cpp | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/Utilities/StrFmt.cpp b/Utilities/StrFmt.cpp index f623919427..b31695df81 100644 --- a/Utilities/StrFmt.cpp +++ b/Utilities/StrFmt.cpp @@ -264,6 +264,19 @@ void fmt_class_string::format(std::string& out, u64 arg) { out += ')'; } + + // Print error code (may be irrelevant) +#ifdef _WIN32 + if (DWORD error = GetLastError()) + { + fmt::append(out, " (e=0x%08x[%u])", error, error); + } +#else + if (int error = errno) + { + fmt::append(out, " (errno=%d)", error); + } +#endif } namespace fmt @@ -271,27 +284,13 @@ namespace fmt void raw_verify_error(const src_loc& loc) { std::string out{"Verification failed"}; - - // Print error code (may be irrelevant) -#ifdef _WIN32 - if (DWORD error = GetLastError()) - { - fmt::append(out, " (e=%#x):", error); - } -#else - if (int error = errno) - { - fmt::append(out, " (e=%d):", error); - } -#endif - fmt::append(out, "%s", loc); thread_ctrl::emergency_exit(out); } void raw_narrow_error(const src_loc& loc, const fmt_type_info* sup, u64 arg) { - std::string out{"Narrow error"}; + std::string out{"Narrowing error"}; if (sup) {