diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2016-01-28 22:25:46 +0900 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2016-01-28 22:25:46 +0900 |
| commit | 25243da03917b7e36a96a3d28bf99cb578501602 (patch) | |
| tree | 32e6f3def966075c1287a4fbc27ed3a6fd060e9f /src/SocketCore.cc | |
| parent | ad6d799b98582250aad50db96519fc7242f6e88a (diff) | |
mingw: Add formatLastError as wrapper function for FormatMessage
Diffstat (limited to 'src/SocketCore.cc')
| -rw-r--r-- | src/SocketCore.cc | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/src/SocketCore.cc b/src/SocketCore.cc index 8358527e..50e974f5 100644 --- a/src/SocketCore.cc +++ b/src/SocketCore.cc @@ -105,14 +105,13 @@ std::string errorMsg(int errNum) #ifndef __MINGW32__ return util::safeStrerror(errNum); #else - static char buf[256]; - if (FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, - nullptr, errNum, - MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), (LPTSTR)&buf, - sizeof(buf), nullptr) == 0) { + auto msg = util::formatLastError(errNum); + if (msg.empty()) { + char buf[256]; snprintf(buf, sizeof(buf), EX_SOCKET_UNKNOWN_ERROR, errNum, errNum); + return buf; } - return buf; + return msg; #endif // __MINGW32__ } } // namespace |
