summaryrefslogtreecommitdiff
path: root/Source/Core/Common/CommonFuncs.cpp
diff options
context:
space:
mode:
authorAdmiral H. Curtiss <pikachu025@gmail.com>2023-07-28 08:10:01 +0200
committerAdmiral H. Curtiss <pikachu025@gmail.com>2023-07-28 08:10:01 +0200
commitcd923718c329118a76e8bcf9a90b959553fbf555 (patch)
treeebf1060921f0bd531027a6fb4d8af4bfe97f2ad8 /Source/Core/Common/CommonFuncs.cpp
parent17fa9dfc4e6007d497b6ae30f6651aaf38672d88 (diff)
CommonFuncs: Add GetWin32ErrorString().
Diffstat (limited to 'Source/Core/Common/CommonFuncs.cpp')
-rw-r--r--Source/Core/Common/CommonFuncs.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/Source/Core/Common/CommonFuncs.cpp b/Source/Core/Common/CommonFuncs.cpp
index a1e93455a2..0a546428b7 100644
--- a/Source/Core/Common/CommonFuncs.cpp
+++ b/Source/Core/Common/CommonFuncs.cpp
@@ -53,9 +53,15 @@ std::string LastStrerrorString()
// This function might change the error code.
std::string GetLastErrorString()
{
+ return GetWin32ErrorString(GetLastError());
+}
+
+// Like GetLastErrorString() but if you have already queried the error code.
+std::string GetWin32ErrorString(DWORD error_code)
+{
char error_message[BUFFER_SIZE];
- FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM, nullptr, GetLastError(),
+ FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM, nullptr, error_code,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), error_message, BUFFER_SIZE, nullptr);
return std::string(error_message);
}