From 9c9b1ae737a9658c87f4fbbf02f3bf7bf95c3e32 Mon Sep 17 00:00:00 2001
From: Moritz Maxeiner <mm@ucw.sh>
Date: Tue, 23 Jul 2019 16:05:54 +0200
Subject: [PATCH] Log windows error code when reading from registry fails

---
 SrcBehaviorLoader/PluginLoader.cpp | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/SrcBehaviorLoader/PluginLoader.cpp b/SrcBehaviorLoader/PluginLoader.cpp
index 59a8673..1f0e632 100644
--- a/SrcBehaviorLoader/PluginLoader.cpp
+++ b/SrcBehaviorLoader/PluginLoader.cpp
@@ -72,15 +72,15 @@ std::vector<std::string> QueryKey(HKEY hKey, std::string path)
                 CHAR szBuffer[512];
                 ULONG dwBufferSize = sizeof(szBuffer);
 
-                if(ERROR_SUCCESS != regKey.Open(HKEY_LOCAL_MACHINE, path.c_str()))
+                if(auto error_code = regKey.Open(HKEY_LOCAL_MACHINE, path.c_str()); error_code != ERROR_SUCCESS)
                 {
-                    qWarning() << "Error opening registry path " << path.c_str(); 
+                    qWarning() << "Error opening windows registry path " << path.c_str() << ": " << error_code;
                     regKey.Close();
                     continue;
                 }
-                if( ERROR_SUCCESS != regKey.QueryStringValue(achValue,szBuffer,&dwBufferSize))
+                if(auto error_code = regKey.QueryStringValue(achValue,szBuffer,&dwBufferSize); error_code != ERROR_SUCCESS)
                 {
-                    qWarning() << "Error opening registry value " << achValue;
+                    qWarning() << "Error opening windows registry value " << achValue << ": " << error_code;
                     regKey.Close();
                     continue;
                 }
-- 
GitLab