martinzink commented on code in PR #1434:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1434#discussion_r1053415102


##########
libminifi/src/utils/OsUtils.cpp:
##########
@@ -284,6 +284,22 @@ int64_t OsUtils::getTotalPagingFileSize() {
   DWORDLONG total_paging_file_size = memory_info.ullTotalPageFile;
   return total_paging_file_size;
 }
+
+std::string OsUtils::getWindowsErrorAsString(DWORD error_code) {
+  if (error_code == 0)
+    return "";
+
+  LPSTR message_buffer = nullptr;
+
+  size_t size = FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | 
FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
+                               nullptr, error_code, MAKELANGID(LANG_NEUTRAL, 
SUBLANG_DEFAULT),
+                               (LPSTR)&message_buffer, 0, nullptr);
+
+  std::string message(message_buffer, size);
+
+  LocalFree(message_buffer);
+  return message;
+}

Review Comment:
   I didn't know these were compatible with each other in this fashion, that 
awesome. (the less windows properitery code we use the better in my opinion) 
Thanks for the tip. I've changed this in 
https://github.com/apache/nifi-minifi-cpp/pull/1434/commits/e142a7d9796ac63ccd4758a9e5a570dae1509fc9#diff-b5759f3732506d7ec0f1b4b4ba184a6f83b4c4b142a2a9202c47afd3ae014cbcR288-R289



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@nifi.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to