MCPcopy Create free account
hub / github.com/Icinga/icinga2 / FormatErrorNumber

Method FormatErrorNumber

lib/base/utility.cpp:1157–1181  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1155}
1156
1157String Utility::FormatErrorNumber(int code) {
1158 std::ostringstream msgbuf;
1159
1160#ifdef _WIN32
1161 char *message;
1162 String result = "Unknown error.";
1163
1164 DWORD rc = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
1165 FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, nullptr, code, 0, (char *)&message,
1166 0, nullptr);
1167
1168 if (rc != 0) {
1169 result = String(message);
1170 LocalFree(message);
1171
1172 /* remove trailing new-line characters */
1173 boost::algorithm::trim_right(result);
1174 }
1175
1176 msgbuf << code << ", \"" << result << "\"";
1177#else
1178 msgbuf << strerror(code);
1179#endif
1180 return msgbuf.str();
1181}
1182
1183String Utility::EscapeShellCmd(const String& s)
1184{

Callers

nothing calls this directly

Calls 1

StringClass · 0.70

Tested by

no test coverage detected