MCPcopy Create free account
hub / github.com/apache/brpc / string SystemErrorCodeToString

Method string SystemErrorCodeToString

src/butil/logging.cc:1500–1513  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1498
1499#if defined(OS_WIN)
1500BUTIL_EXPORT std::string SystemErrorCodeToString(SystemErrorCode error_code) {
1501 const int error_message_buffer_size = 256;
1502 char msgbuf[error_message_buffer_size];
1503 DWORD flags = FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS;
1504 DWORD len = FormatMessageA(flags, NULL, error_code, 0, msgbuf,
1505 arraysize(msgbuf), NULL);
1506 if (len) {
1507 // Messages returned by system end with line breaks.
1508 return butil::CollapseWhitespaceASCII(msgbuf, true) +
1509 butil::StringPrintf(" (0x%X)", error_code);
1510 }
1511 return butil::StringPrintf("Error (0x%X) while retrieving error. (0x%X)",
1512 GetLastError(), error_code);
1513}
1514#elif defined(OS_POSIX)
1515BUTIL_EXPORT std::string SystemErrorCodeToString(SystemErrorCode error_code) {
1516 return berror(error_code);

Callers

nothing calls this directly

Calls 3

CollapseWhitespaceASCIIFunction · 0.85
StringPrintfFunction · 0.85
berrorFunction · 0.85

Tested by

no test coverage detected