errorString.get(); returns something like "Foo\n" and hence adding the trailing period (and subsequent DWORD error to string) ends up in a new line.
From
|
std::string GetErrorMessage(DWORD error) |
|
{ |
|
std::string errorMessage = " Error Code: " + std::to_string(error); |
|
|
|
char* errorMsg = nullptr; |
|
if (FormatMessage( |
|
FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_FROM_HMODULE | FORMAT_MESSAGE_ALLOCATE_BUFFER, |
|
GetModuleHandle("winhttp.dll"), |
|
error, |
|
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), |
|
reinterpret_cast<LPSTR>(&errorMsg), |
|
0, |
|
nullptr) |
|
!= 0) |
|
{ |
|
// Use a unique_ptr to manage the lifetime of errorMsg. |
|
std::unique_ptr<char, decltype(&LocalFree)> errorString(errorMsg, &LocalFree); |
|
errorMsg = nullptr; |
|
|
|
errorMessage += ": "; |
|
errorMessage += errorString.get(); |
|
} |
|
errorMessage += '.'; |
|
return errorMessage; |
|
} |
The logs, which also end up emitting the exception message (in the transport layer) end up like this:
[2023-11-10T23:26:43.1726294Z T: 38480] INFO : Status operation: 2097152(WINHTTP_CALLBACK_STATUS_REQUEST_ERROR )
[2023-11-10T23:26:43.1733686Z T: 38480] ERROR : Request error. Error Code: 12002: The operation timed out
. 1
[2023-11-10T23:26:43.1738532Z T: 38480] DEBUG : WinHttpRequest::~WinHttpRequest. Closing handle synchronously.

cc @LarryOsterman
errorString.get();returns something like "Foo\n" and hence adding the trailing period (and subsequent DWORD error to string) ends up in a new line.From
azure-sdk-for-cpp/sdk/core/azure-core/src/http/winhttp/win_http_transport.cpp
Lines 401 to 425 in 083d52a
The logs, which also end up emitting the exception message (in the transport layer) end up like this:
cc @LarryOsterman