Cuberite
A lightweight, fast and extensible game server for Minecraft
GetAddressInfoError.h
Go to the documentation of this file.
1 #pragma once
2 
3 
4 
6 inline AString ErrorString(int a_ErrorCode)
7 {
8  // Note gai_strerror is not threadsafe on windows
9  #ifdef _WIN32
10  char ErrorStr[GAI_STRERROR_BUFFER_SIZE + 1];
11 
12  int MsgLen = FormatMessageA(
13  FORMAT_MESSAGE_FROM_SYSTEM |
14  FORMAT_MESSAGE_IGNORE_INSERTS |
15  FORMAT_MESSAGE_MAX_WIDTH_MASK,
16  nullptr,
17  a_ErrorCode,
18  MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
19  ErrorStr,
20  sizeof(ErrorStr) - 1,
21  nullptr
22  );
23 
24  return AString(ErrorStr, MsgLen);
25  #else
26  return gai_strerror(a_ErrorCode);
27  #endif
28 }
29 
AString ErrorString(int a_ErrorCode)
Returns the readable form of a getaddressinfo type error code.
std::string AString
Definition: StringUtils.h:11