MCPcopy Create free account
hub / github.com/PolyMC/PolyMC / processReply

Method processReply

launcher/minecraft/auth/Yggdrasil.cpp:260–353  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

258}
259
260void Yggdrasil::processReply() {
261 changeState(AccountTaskState::STATE_WORKING);
262
263 switch (m_netReply->error())
264 {
265 case QNetworkReply::NoError:
266 break;
267 case QNetworkReply::TimeoutError:
268 changeState(AccountTaskState::STATE_FAILED_SOFT, tr("Authentication operation timed out."));
269 return;
270 case QNetworkReply::OperationCanceledError:
271 changeState(AccountTaskState::STATE_FAILED_SOFT, tr("Authentication operation cancelled."));
272 return;
273 case QNetworkReply::SslHandshakeFailedError:
274 changeState(
275 AccountTaskState::STATE_FAILED_SOFT,
276 tr(
277 "<b>SSL Handshake failed.</b><br/>There might be a few causes for it:<br/>"
278 "<ul>"
279 "<li>You use Windows and need to update your root certificates, please install any outstanding updates.</li>"
280 "<li>Some device on your network is interfering with SSL traffic. In that case, "
281 "you have bigger worries than Minecraft not starting.</li>"
282 "<li>Possibly something else. Check the log file for details</li>"
283 "</ul>"
284 )
285 );
286 return;
287 // used for invalid credentials and similar errors. Fall through.
288 case QNetworkReply::ContentAccessDenied:
289 case QNetworkReply::ContentOperationNotPermittedError:
290 break;
291 case QNetworkReply::ContentGoneError: {
292 changeState(
293 AccountTaskState::STATE_FAILED_GONE,
294 tr("The Mojang account no longer exists. It may have been migrated to a Microsoft account.")
295 );
296 break;
297 }
298 default:
299 changeState(
300 AccountTaskState::STATE_FAILED_SOFT,
301 tr("Authentication operation failed due to a network error: %1 (%2)").arg(m_netReply->errorString()).arg(m_netReply->error())
302 );
303 return;
304 }
305
306 // Try to parse the response regardless of the response code.
307 // Sometimes the auth server will give more information and an error code.
308 QJsonParseError jsonError;
309 QByteArray replyData = m_netReply->readAll();
310 QJsonDocument doc = QJsonDocument::fromJson(replyData, &jsonError);
311 // Check the response code.
312 int responseCode = m_netReply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
313
314 if (responseCode == 200) {
315 // If the response code was 200, then there shouldn't be an error. Make sure
316 // anyways.
317 // Also, sometimes an empty reply indicates success. If there was no data received,

Callers

nothing calls this directly

Calls 4

fromJsonFunction · 0.85
errorMethod · 0.80
objectMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected