mirror of
https://github.com/MultiMC/MultiMC5.git
synced 2025-03-14 13:20:59 +00:00
NOISSUE handle a weird corner case when creatin a Minecraft profile
The server can return an error with details status "ALREADY_REGISTERED" instead of success.
This commit is contained in:
parent
beea53682e
commit
cfb716daa5
@ -213,15 +213,21 @@ struct MojangError{
|
||||
auto doc = QJsonDocument::fromJson(data, &out.parseError);
|
||||
if(out.parseError.error != QJsonParseError::NoError)
|
||||
{
|
||||
out.fullyParsed = false;
|
||||
out.jsonParsed = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
out.fullyParsed = true;
|
||||
auto object = doc.object();
|
||||
out.fullyParsed &= Parsers::getString(object.value("path"), out.path);
|
||||
out.fullyParsed &= Parsers::getString(object.value("error"), out.error);
|
||||
out.fullyParsed &= Parsers::getString(object.value("errorMessage"), out.errorMessage);
|
||||
Parsers::getString(object.value("path"), out.path);
|
||||
QJsonValue details = object.value("details");
|
||||
if(details.isObject())
|
||||
{
|
||||
QJsonObject detailsObj = details.toObject();
|
||||
Parsers::getString(detailsObj.value("status"), out.detailsStatus);
|
||||
}
|
||||
Parsers::getString(object.value("error"), out.error);
|
||||
Parsers::getString(object.value("errorMessage"), out.errorMessage);
|
||||
out.jsonParsed = true;
|
||||
}
|
||||
|
||||
|
||||
@ -232,11 +238,24 @@ struct MojangError{
|
||||
QString outString;
|
||||
QTextStream out(&outString);
|
||||
out << "Network error:" << networkError << "\n";
|
||||
if(fullyParsed)
|
||||
if(jsonParsed)
|
||||
{
|
||||
out << "path: " << path << "\n";
|
||||
out << "error: " << error << "\n";
|
||||
out << "errorMessage: " << errorMessage << "\n";
|
||||
if(!path.isNull())
|
||||
{
|
||||
out << "path: " << path << "\n";
|
||||
}
|
||||
if(!error.isNull())
|
||||
{
|
||||
out << "error: " << error << "\n";
|
||||
}
|
||||
if(!errorMessage.isNull())
|
||||
{
|
||||
out << "errorMessage: " << errorMessage << "\n";
|
||||
}
|
||||
if(!detailsStatus.isNull())
|
||||
{
|
||||
out << "details.status: " << detailsStatus << "\n";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -250,11 +269,12 @@ struct MojangError{
|
||||
QString rawError;
|
||||
|
||||
QJsonParseError parseError;
|
||||
bool fullyParsed;
|
||||
bool jsonParsed = false;
|
||||
|
||||
QString path;
|
||||
QString error;
|
||||
QString errorMessage;
|
||||
QString detailsStatus;
|
||||
};
|
||||
|
||||
}
|
||||
@ -274,9 +294,16 @@ void ProfileSetupDialog::setupProfileFinished(
|
||||
* ... we could parse it and update the account, but let's just return back to the normal login flow instead...
|
||||
*/
|
||||
accept();
|
||||
return;
|
||||
}
|
||||
else {
|
||||
auto parsedError = MojangError::fromJSON(data, error);
|
||||
// Apparently, this is something that can happen...
|
||||
if(parsedError.detailsStatus == "ALREADY_REGISTERED")
|
||||
{
|
||||
accept();
|
||||
return;
|
||||
}
|
||||
ui->errorLabel->setVisible(true);
|
||||
QString errorString = parsedError.toString();
|
||||
ui->errorLabel->setText(tr("The server returned the following error:") + "\n\n" + errorString);
|
||||
|
Loading…
x
Reference in New Issue
Block a user