Use suggested error handling

This commit is contained in:
TheCodex6824 2022-04-25 14:08:27 -04:00
parent a0bafa4952
commit 1ff459d995
No known key found for this signature in database
GPG Key ID: E9EBC39837469118

View File

@ -1,4 +1,5 @@
#include "Parsers.h" #include "Parsers.h"
#include "Json.h"
#include <QJsonDocument> #include <QJsonDocument>
#include <QJsonArray> #include <QJsonArray>
@ -285,7 +286,7 @@ bool parseMinecraftProfileMojang(QByteArray & data, MinecraftProfile &output) {
return false; return false;
} }
auto obj = doc.object(); auto obj = Json::requireObject(doc, "mojang minecraft profile");
if(!getString(obj.value("id"), output.id)) { if(!getString(obj.value("id"), output.id)) {
qWarning() << "Minecraft profile id is not a string"; qWarning() << "Minecraft profile id is not a string";
return false; return false;
@ -330,7 +331,7 @@ bool parseMinecraftProfileMojang(QByteArray & data, MinecraftProfile &output) {
return false; return false;
} }
obj = doc.object(); obj = Json::requireObject(doc, "session texture payload");
auto textures = obj.value("textures"); auto textures = obj.value("textures");
if (!textures.isObject()) { if (!textures.isObject()) {
qWarning() << "No textures array in response"; qWarning() << "No textures array in response";