Common/Network: Add StrNetworkError helper function

This commit is contained in:
Sepalani 2022-08-24 20:34:49 +04:00
parent b6ac63dc47
commit e783a7f409
2 changed files with 11 additions and 0 deletions

View File

@ -566,4 +566,14 @@ const char* DecodeNetworkError(s32 error_code)
return strerror_r(error_code, buffer, sizeof(buffer));
#endif
}
const char* StrNetworkError()
{
#ifdef _WIN32
const s32 error_code = WSAGetLastError();
#else
const s32 error_code = errno;
#endif
return DecodeNetworkError(error_code);
}
} // namespace Common

View File

@ -266,4 +266,5 @@ u16 ComputeTCPNetworkChecksum(const IPAddress& from, const IPAddress& to, const
NetworkErrorState SaveNetworkErrorState();
void RestoreNetworkErrorState(const NetworkErrorState& state);
const char* DecodeNetworkError(s32 error_code);
const char* StrNetworkError();
} // namespace Common