MCPcopy Create free account
hub / github.com/DFHack/dfhack / get_error

Function get_error

library/PlugLoad.cpp:44–65  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

42
43 namespace {
44 std::string get_error()
45 {
46#ifdef WIN32
47 DWORD error = GetLastError();
48 LPSTR buf = NULL;
49 DWORD len = FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
50 NULL, error, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPSTR)&buf, 0, NULL);
51 if (len > 0) {
52 std::string message{ buf };
53 LocalFree(buf);
54 return message;
55 }
56 std::ostringstream b{};
57 b << "unknown error " << error;
58 return b.str();
59#else
60 char* error = dlerror();
61 if (error)
62 return std::string{ error };
63 return std::string{};
64#endif
65 }
66 }
67
68 DFLibrary * OpenPlugin (std::filesystem::path filename)

Callers 2

OpenPluginFunction · 0.85
ClosePluginFunction · 0.85

Calls 1

strMethod · 0.45

Tested by

no test coverage detected