| 187 | } |
| 188 | |
| 189 | std::string KeyHandler::FormatSystemError(LSTATUS status) |
| 190 | { |
| 191 | std::string formattedMessage{ "Windows Registry: unexpected error." }; |
| 192 | LPWSTR message = nullptr; |
| 193 | DWORD size = 1024; |
| 194 | if (FormatMessageW( |
| 195 | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER, nullptr, |
| 196 | status, 0, reinterpret_cast<LPWSTR>(&message), size, nullptr) != 0) { |
| 197 | try { |
| 198 | formattedMessage = cmTrimWhitespace(ToNarrow(message)); |
| 199 | } catch (...) { |
| 200 | // ignore any exception because this method can be called |
| 201 | // as part of the raise of an exception |
| 202 | } |
| 203 | } |
| 204 | LocalFree(message); |
| 205 | |
| 206 | return formattedMessage; |
| 207 | } |
| 208 | |
| 209 | std::wstring KeyHandler::ToWide(cm::string_view str) |
| 210 | { |
no test coverage detected