CoreCon: Improve error messaging
authorAndrew Knight <andrew.knight@digia.com>
Mon, 24 Mar 2014 13:16:58 +0000 (15:16 +0200)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Mon, 24 Mar 2014 18:15:53 +0000 (19:15 +0100)
This adds another HRESULT_FACILITY to the conmanui whitelist, and adds
fallback to qt_error_string if the string is not found.

Change-Id: Ib4dddeca5cf5ba76e3c7fc5254f85e5a6949febe
Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>
Reviewed-by: Oliver Wolff <oliver.wolff@digia.com>
src/shared/corecon/corecon.cpp

index 579d779..683e219 100644 (file)
@@ -353,11 +353,12 @@ QString CoreConServer::formatError(HRESULT hr) const
     wchar_t error[1024];
     HMODULE module = 0;
     DWORD origin = HRESULT_FACILITY(hr);
-    if (origin == 0x973 || origin == 0x974)
+    if (origin == 0x973 || origin == 0x974 || origin == 0x103)
         module = d->langModule;
-    if (module)
-        LoadString(module, HRESULT_CODE(hr), error, sizeof(error)/sizeof(wchar_t));
-    else
-        FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, hr, 0, error, sizeof(error)/sizeof(wchar_t), NULL);
-    return QString::fromWCharArray(error).trimmed();
+    if (module) {
+        int length = LoadString(module, HRESULT_CODE(hr), error, sizeof(error)/sizeof(wchar_t));
+        if (length)
+            return QString::fromWCharArray(error, length).trimmed();
+    }
+    return qt_error_string(hr);
 }