Tiny simplification in wxWebRequestWinHTTP code

Add and use SetFailed(error) function for symmetry with the existing
SetFailedWithLastError().
This commit is contained in:
Vadim Zeitlin
2021-01-05 00:41:21 +01:00
parent dbc1d9c40e
commit d22956a56a
2 changed files with 8 additions and 4 deletions

View File

@@ -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;

View File

@@ -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);
}