MCPcopy Create free account
hub / github.com/NVIDIA/cccl / getWindowsError

Function getWindowsError

c/parallel/src/hostjit/loader.cpp:44–78  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

42}
43
44std::string getWindowsError()
45{
46 DWORD error = GetLastError();
47 if (error == 0)
48 {
49 return "";
50 }
51
52 LPSTR buffer = nullptr;
53 DWORD size = FormatMessageA(
54 FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
55 nullptr,
56 error,
57 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
58 reinterpret_cast<LPSTR>(&buffer),
59 0,
60 nullptr);
61
62 std::string message;
63 if (size > 0 && buffer)
64 {
65 message = std::string(buffer, size);
66 while (!message.empty() && (message.back() == '\n' || message.back() == '\r'))
67 {
68 message.pop_back();
69 }
70 LocalFree(buffer);
71 }
72 else
73 {
74 message = "Unknown error (code: " + std::to_string(error) + ")";
75 }
76
77 return message;
78}
79} // anonymous namespace
80#endif
81

Callers 2

loadMethod · 0.85
getSymbolMethod · 0.85

Calls 4

to_stringFunction · 0.85
emptyMethod · 0.45
backMethod · 0.45
pop_backMethod · 0.45

Tested by

no test coverage detected