fix: handle json exception in FileResolvingTask
Also needed to add a call to loop.exit() in FlameInstanceCreationTask so that it would handle the failure of FileResolvingTask properly Signed-off-by: Lenny McLennington <lenny@sneed.church>
This commit is contained in:
parent
edd650aacd
commit
33634764e9
@ -85,7 +85,6 @@ private slots:
|
|||||||
|
|
||||||
private: /* data */
|
private: /* data */
|
||||||
NetJob::Ptr m_filesNetJob;
|
NetJob::Ptr m_filesNetJob;
|
||||||
shared_qobject_ptr<Flame::FileResolvingTask> m_modIdResolver;
|
|
||||||
QUrl m_sourceUrl;
|
QUrl m_sourceUrl;
|
||||||
QString m_archivePath;
|
QString m_archivePath;
|
||||||
bool m_downloadRequired = false;
|
bool m_downloadRequired = false;
|
||||||
|
@ -41,7 +41,17 @@ void Flame::FileResolvingTask::netJobFinished()
|
|||||||
// job to check modrinth for blocked projects
|
// job to check modrinth for blocked projects
|
||||||
auto job = new NetJob("Modrinth check", m_network);
|
auto job = new NetJob("Modrinth check", m_network);
|
||||||
blockedProjects = QMap<File *,QByteArray *>();
|
blockedProjects = QMap<File *,QByteArray *>();
|
||||||
auto doc = Json::requireDocument(*result);
|
QJsonDocument doc;
|
||||||
|
|
||||||
|
try {
|
||||||
|
doc = Json::requireDocument(*result);
|
||||||
|
}
|
||||||
|
catch (const JSONValidationError &e) {
|
||||||
|
qDebug() << "Flame::FileResolvingTask: Json Validation error: " << e.what();
|
||||||
|
emitFailed(e.what());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
auto array = Json::requireArray(doc.object()["data"]);
|
auto array = Json::requireArray(doc.object()["data"]);
|
||||||
for (QJsonValueRef file : array) {
|
for (QJsonValueRef file : array) {
|
||||||
auto fileid = Json::requireInteger(Json::requireObject(file)["id"]);
|
auto fileid = Json::requireInteger(Json::requireObject(file)["id"]);
|
||||||
|
@ -335,9 +335,10 @@ bool FlameCreationTask::createInstance()
|
|||||||
|
|
||||||
m_mod_id_resolver = new Flame::FileResolvingTask(APPLICATION->network(), m_pack);
|
m_mod_id_resolver = new Flame::FileResolvingTask(APPLICATION->network(), m_pack);
|
||||||
connect(m_mod_id_resolver.get(), &Flame::FileResolvingTask::succeeded, this, [this, &loop] { idResolverSucceeded(loop); });
|
connect(m_mod_id_resolver.get(), &Flame::FileResolvingTask::succeeded, this, [this, &loop] { idResolverSucceeded(loop); });
|
||||||
connect(m_mod_id_resolver.get(), &Flame::FileResolvingTask::failed, [&](QString reason) {
|
connect(m_mod_id_resolver.get(), &Flame::FileResolvingTask::failed, [this, &loop](QString reason) {
|
||||||
m_mod_id_resolver.reset();
|
m_mod_id_resolver.reset();
|
||||||
setError(tr("Unable to resolve mod IDs:\n") + reason);
|
setError(tr("Unable to resolve mod IDs:\n") + reason);
|
||||||
|
loop.exit();
|
||||||
});
|
});
|
||||||
connect(m_mod_id_resolver.get(), &Flame::FileResolvingTask::progress, this, &FlameCreationTask::setProgress);
|
connect(m_mod_id_resolver.get(), &Flame::FileResolvingTask::progress, this, &FlameCreationTask::setProgress);
|
||||||
connect(m_mod_id_resolver.get(), &Flame::FileResolvingTask::status, this, &FlameCreationTask::setStatus);
|
connect(m_mod_id_resolver.get(), &Flame::FileResolvingTask::status, this, &FlameCreationTask::setStatus);
|
||||||
|
Loading…
Reference in New Issue
Block a user