MCPcopy Create free account
hub / github.com/apache/brpc / berror

Function berror

src/butil/errno.cpp:73–97  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

71} // namespace butil
72
73const char* berror(int error_code) {
74 if (error_code == -1) {
75 return "General error -1";
76 }
77 if (error_code >= butil::ERRNO_BEGIN && error_code < butil::ERRNO_END) {
78 const char* s = butil::errno_desc[error_code - butil::ERRNO_BEGIN];
79 if (s) {
80 return s;
81 }
82#if defined(OS_MACOSX)
83 const int rc = strerror_r(error_code, butil::tls_error_buf, butil::ERROR_BUFSIZE);
84 if (rc == 0 || rc == ERANGE/*bufsize is not long enough*/) {
85 return butil::tls_error_buf;
86 }
87#else
88 s = strerror_r(error_code, butil::tls_error_buf, butil::ERROR_BUFSIZE);
89 if (s) {
90 return s;
91 }
92#endif
93 }
94 snprintf(butil::tls_error_buf, butil::ERROR_BUFSIZE,
95 "Unknown error %d", error_code);
96 return butil::tls_error_buf;
97}
98
99const char* berror() {
100 return berror(errno);

Callers 15

TEST_FFunction · 0.85
TESTFunction · 0.85
client_threadFunction · 0.85
TESTFunction · 0.85
TESTFunction · 0.85
TEST_FFunction · 0.85
select_serverFunction · 0.85
TEST_FFunction · 0.85
WriterFunction · 0.85
FastWriterFunction · 0.85
TEST_FFunction · 0.85
TESTFunction · 0.85

Calls 1

snprintfFunction · 0.85

Tested by 13

TEST_FFunction · 0.68
TESTFunction · 0.68
client_threadFunction · 0.68
TESTFunction · 0.68
TESTFunction · 0.68
TEST_FFunction · 0.68
select_serverFunction · 0.68
TEST_FFunction · 0.68
WriterFunction · 0.68
FastWriterFunction · 0.68
TEST_FFunction · 0.68
TESTFunction · 0.68