mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-16 11:48:06 +01: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:
@@ -11,12 +11,6 @@
|
||||
#pragma comment(lib, "advapi32.lib")
|
||||
#pragma comment(lib, "shlwapi.lib")
|
||||
|
||||
namespace localized_strings
|
||||
{
|
||||
const wchar_t LAST_ERROR_FORMAT_STRING[] = L"%s failed with error %d: %s";
|
||||
const wchar_t LAST_ERROR_TITLE_STRING[] = L"Error";
|
||||
}
|
||||
|
||||
std::optional<RECT> get_window_pos(HWND hwnd)
|
||||
{
|
||||
RECT window;
|
||||
@@ -91,7 +85,7 @@ std::optional<std::wstring> get_last_error_message(const DWORD dw)
|
||||
return message;
|
||||
}
|
||||
|
||||
void show_last_error_message(LPCWSTR lpszFunction, DWORD dw)
|
||||
void show_last_error_message(LPCWSTR lpszFunction, DWORD dw, LPCWSTR errorTitle)
|
||||
{
|
||||
const auto system_message = get_last_error_message(dw);
|
||||
if (!system_message.has_value())
|
||||
@@ -107,7 +101,7 @@ void show_last_error_message(LPCWSTR lpszFunction, DWORD dw)
|
||||
lpszFunction,
|
||||
dw,
|
||||
system_message->c_str());
|
||||
MessageBoxW(NULL, (LPCTSTR)lpDisplayBuf, localized_strings::LAST_ERROR_TITLE_STRING, MB_OK);
|
||||
MessageBoxW(NULL, (LPCTSTR)lpDisplayBuf, errorTitle, MB_OK | MB_ICONERROR);
|
||||
LocalFree(lpDisplayBuf);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user