MCPcopy Create free account
hub / github.com/CppMicroServices/CppMicroServices / GetLastCErrorStr

Function GetLastCErrorStr

util/src/Error.cpp:78–109  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

76#endif
77
78 std::string
79 GetLastCErrorStr()
80 {
81 char errorString[128];
82#if ((_POSIX_C_SOURCE >= 200112L) && !_GNU_SOURCE) || defined(US_PLATFORM_APPLE)
83 // This is the XSI strerror_r version
84 int en = errno;
85 int r = strerror_r(errno, errorString, sizeof errorString);
86 if (r)
87 {
88 std::string errMsg = "Unknown error " + util::ToString(en) + ": strerror_r failed with error code ";
89 if (r < 0)
90 {
91 errMsg += util::ToString(static_cast<int>(errno));
92 }
93 else
94 {
95 errMsg += util::ToString(r);
96 }
97 return errMsg;
98 }
99 return errorString;
100#elif defined(US_PLATFORM_WINDOWS)
101 if (strerror_s(errorString, sizeof errorString, errno))
102 {
103 return "Unknown error";
104 }
105 return errorString;
106#else
107 return strerror_r(errno, errorString, sizeof errorString);
108#endif
109 }
110
111 std::string
112 GetExceptionStr(std::exception_ptr const& exc)

Callers 9

ChangeDirectoryFunction · 0.85
MakeUniqueTempDirectoryFunction · 0.85
MakeUniqueTempFileFunction · 0.85
ExistsFunction · 0.85
IsDirectoryFunction · 0.85
IsFileFunction · 0.85
MakePathFunction · 0.85
RemoveDirectoryRecursiveFunction · 0.85
FileSystem.cppFile · 0.85

Calls 1

ToStringFunction · 0.50

Tested by 3

ChangeDirectoryFunction · 0.68
MakeUniqueTempDirectoryFunction · 0.68
MakeUniqueTempFileFunction · 0.68