MCPcopy Create free account
hub / github.com/citron-neo/emulator / NativeErrorToString

Function NativeErrorToString

src/common/error.cpp:17–47  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15namespace Common {
16
17std::string NativeErrorToString(int e) {
18#ifdef _WIN32
19 LPSTR err_str;
20
21 DWORD res = FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER |
22 FORMAT_MESSAGE_IGNORE_INSERTS,
23 nullptr, e, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
24 reinterpret_cast<LPSTR>(&err_str), 1, nullptr);
25 if (!res) {
26 return "(FormatMessageA failed to format error)";
27 }
28 std::string ret(err_str);
29 LocalFree(err_str);
30 return ret;
31#else
32 char err_str[255];
33#if defined(ANDROID) || \
34 (defined(__GLIBC__) && (_GNU_SOURCE || (_POSIX_C_SOURCE < 200112L && _XOPEN_SOURCE < 600)))
35 // Thread safe (GNU-specific)
36 const char* str = strerror_r(e, err_str, sizeof(err_str));
37 return std::string(str);
38#else
39 // Thread safe (XSI-compliant)
40 int second_err = strerror_r(e, err_str, sizeof(err_str));
41 if (second_err != 0) {
42 return "(strerror_r failed to format error)";
43 }
44 return std::string(err_str);
45#endif // GLIBC etc.
46#endif // _WIN32
47}
48
49std::string GetLastErrorMsg() {
50#ifdef _WIN32

Callers 8

OneTimeInitFunction · 0.85
GrabStreamSizesMethod · 0.85
ReadMethod · 0.85
WriteMethod · 0.85
GetServerCertsMethod · 0.85
GetAndLogLastErrorFunction · 0.85
GetLastErrorMsgFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected