From d22956a56a549ef9885132d11f3af0d3255b1501 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 5 Jan 2021 00:41:21 +0100 Subject: [PATCH] Tiny simplification in wxWebRequestWinHTTP code Add and use SetFailed(error) function for symmetry with the existing SetFailedWithLastError(). --- include/wx/msw/private/webrequest_winhttp.h | 6 +++++- src/msw/webrequest_winhttp.cpp | 6 +++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/include/wx/msw/private/webrequest_winhttp.h b/include/wx/msw/private/webrequest_winhttp.h index ad21393ec1..91620bc444 100644 --- a/include/wx/msw/private/webrequest_winhttp.h +++ b/include/wx/msw/private/webrequest_winhttp.h @@ -109,7 +109,11 @@ private: void CreateResponse(); - void SetFailedWithLastError(); + // Retrieve the error message corresponding to the given error and set the + // state to failed with this message as error string. + void SetFailed(DWORD errorCode); + + void SetFailedWithLastError() { SetFailed(::GetLastError()); } friend class wxWebAuthChallengeWinHTTP; diff --git a/src/msw/webrequest_winhttp.cpp b/src/msw/webrequest_winhttp.cpp index 46ed71bd7a..49532ea78a 100644 --- a/src/msw/webrequest_winhttp.cpp +++ b/src/msw/webrequest_winhttp.cpp @@ -196,7 +196,7 @@ void wxWebRequestWinHTTP::HandleCallback(DWORD dwInternetStatus, GetState() == wxWebRequest::State_Cancelled ) SetState(wxWebRequest::State_Cancelled); else - SetState(wxWebRequest::State_Failed, wxWinHTTPErrorToString(asyncResult->dwError)); + SetFailed(asyncResult->dwError); break; } } @@ -252,9 +252,9 @@ void wxWebRequestWinHTTP::CreateResponse() SetFailedWithLastError(); } -void wxWebRequestWinHTTP::SetFailedWithLastError() +void wxWebRequestWinHTTP::SetFailed(DWORD errorCode) { - wxString failMessage = wxWinHTTPErrorToString(::GetLastError()); + wxString failMessage = wxWinHTTPErrorToString(errorCode); SetState(wxWebRequest::State_Failed, failMessage); }