MCPcopy Create free account
hub / github.com/apache/arrow / WinErrorMessage

Function WinErrorMessage

cpp/src/arrow/util/io_util.cc:214–235  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

212
213#if _WIN32
214std::string WinErrorMessage(int errnum) {
215 constexpr DWORD max_n_chars = 1024;
216 WCHAR utf16_message[max_n_chars];
217 auto n_utf16_chars =
218 FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL,
219 errnum, 0, utf16_message, max_n_chars, NULL);
220 if (n_utf16_chars == 0) {
221 // Fallback
222 std::stringstream ss;
223 ss << "Windows error #" << errnum;
224 return ss.str();
225 }
226 auto utf8_message_result =
227 arrow::util::WideStringToUTF8(std::wstring(utf16_message, n_utf16_chars));
228 if (!utf8_message_result.ok()) {
229 std::stringstream ss;
230 ss << "Windows error #" << errnum;
231 ss << "; failed to convert error message to UTF-8: " << utf8_message_result.status();
232 return ss.str();
233 }
234 return *utf8_message_result;
235}
236#endif
237
238namespace {

Callers 3

GetListenPortFunction · 0.85
ToStringMethod · 0.85
FindHandleDeleterFunction · 0.85

Calls 3

strMethod · 0.80
okMethod · 0.45
statusMethod · 0.45

Tested by

no test coverage detected