mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-05 10:46:33 +02:00
Add in verbose error message and telemetry for SetWindowsHookEx failure (#6454)
* Updated error message when SetWindowsHookEx fails to show correct error message * Added telemetry for exception in SG, FZ and KBM * Rename exception to error
This commit is contained in:
@@ -82,10 +82,10 @@ public:
|
||||
s_llKeyboardHook = SetWindowsHookEx(WH_KEYBOARD_LL, LowLevelKeyboardProc, GetModuleHandle(NULL), NULL);
|
||||
if (!s_llKeyboardHook)
|
||||
{
|
||||
MessageBoxW(NULL,
|
||||
GET_RESOURCE_STRING(IDS_KEYBOARD_LISTENER_ERROR).c_str(),
|
||||
GET_RESOURCE_STRING(IDS_POWERTOYS_FANCYZONES).c_str(),
|
||||
MB_OK | MB_ICONERROR);
|
||||
DWORD errorCode = GetLastError();
|
||||
show_last_error_message(L"SetWindowsHookEx", errorCode, GET_RESOURCE_STRING(IDS_POWERTOYS_FANCYZONES).c_str());
|
||||
auto errorMessage = get_last_error_message(errorCode);
|
||||
Trace::FancyZones::Error(errorCode, errorMessage.has_value() ? errorMessage.value() : L"", L"enable.SetWindowsHookEx");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -213,6 +213,19 @@ void Trace::FancyZones::EditorLaunched(int value) noexcept
|
||||
TraceLoggingInt32(value, EditorLaunchValueKey));
|
||||
}
|
||||
|
||||
// Log if an error occurs in FZ
|
||||
void Trace::FancyZones::Error(const DWORD errorCode, std::wstring errorMessage, std::wstring methodName) noexcept
|
||||
{
|
||||
TraceLoggingWrite(
|
||||
g_hProvider,
|
||||
"FancyZones_Error",
|
||||
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
|
||||
TraceLoggingKeyword(PROJECT_KEYWORD_MEASURE),
|
||||
TraceLoggingValue(methodName.c_str(), "MethodName"),
|
||||
TraceLoggingValue(errorCode, "ErrorCode"),
|
||||
TraceLoggingValue(errorMessage.c_str(), "ErrorMessage"));
|
||||
}
|
||||
|
||||
void Trace::SettingsChanged(const Settings& settings) noexcept
|
||||
{
|
||||
const auto& editorHotkey = settings.editorHotkey;
|
||||
|
||||
@@ -16,6 +16,7 @@ public:
|
||||
static void OnKeyDown(DWORD vkCode, bool win, bool control, bool inMoveSize) noexcept;
|
||||
static void DataChanged() noexcept;
|
||||
static void EditorLaunched(int value) noexcept;
|
||||
static void Error(const DWORD errorCode, std::wstring errorMessage, std::wstring methodName) noexcept;
|
||||
};
|
||||
|
||||
static void SettingsChanged(const Settings& settings) noexcept;
|
||||
|
||||
Reference in New Issue
Block a user