From d6dc22d57c33497b5908abaf53770cde1773c0a7 Mon Sep 17 00:00:00 2001 From: Jamie Mansfield Date: Mon, 5 Apr 2021 21:19:05 +0100 Subject: [PATCH] NOISSUE Handle JSON exceptions in ATLauncher support Thanks to phit for pointing this out :) --- application/CMakeLists.txt | 5 ++--- .../atlauncher/{AtlModel.cpp => AtlListModel.cpp} | 13 +++++++++++-- .../atlauncher/{AtlModel.h => AtlListModel.h} | 0 application/pages/modplatform/atlauncher/AtlPage.h | 2 +- 4 files changed, 14 insertions(+), 6 deletions(-) rename application/pages/modplatform/atlauncher/{AtlModel.cpp => AtlListModel.cpp} (93%) rename application/pages/modplatform/atlauncher/{AtlModel.h => AtlListModel.h} (100%) diff --git a/application/CMakeLists.txt b/application/CMakeLists.txt index afd13574f..fd49c2673 100644 --- a/application/CMakeLists.txt +++ b/application/CMakeLists.txt @@ -125,13 +125,12 @@ SET(MULTIMC_SOURCES pages/modplatform/VanillaPage.cpp pages/modplatform/VanillaPage.h - pages/modplatform/atlauncher/AtlModel.cpp - pages/modplatform/atlauncher/AtlModel.h pages/modplatform/atlauncher/AtlFilterModel.cpp pages/modplatform/atlauncher/AtlFilterModel.h + pages/modplatform/atlauncher/AtlListModel.cpp + pages/modplatform/atlauncher/AtlListModel.h pages/modplatform/atlauncher/AtlPage.cpp pages/modplatform/atlauncher/AtlPage.h - pages/modplatform/atlauncher/AtlPage.h pages/modplatform/ftb/FtbFilterModel.cpp pages/modplatform/ftb/FtbFilterModel.h diff --git a/application/pages/modplatform/atlauncher/AtlModel.cpp b/application/pages/modplatform/atlauncher/AtlListModel.cpp similarity index 93% rename from application/pages/modplatform/atlauncher/AtlModel.cpp rename to application/pages/modplatform/atlauncher/AtlListModel.cpp index 4b1b1c8e0..f3be61989 100644 --- a/application/pages/modplatform/atlauncher/AtlModel.cpp +++ b/application/pages/modplatform/atlauncher/AtlListModel.cpp @@ -1,8 +1,9 @@ -#include "AtlModel.h" +#include "AtlListModel.h" #include #include #include +#include namespace Atl { @@ -99,7 +100,15 @@ void ListModel::requestFinished() auto packObj = packRaw.toObject(); ATLauncher::IndexedPack pack; - ATLauncher::loadIndexedPack(pack, packObj); + + try { + ATLauncher::loadIndexedPack(pack, packObj); + } + catch (const JSONValidationError &e) { + qDebug() << QString::fromUtf8(response); + qWarning() << "Error while reading pack manifest from ATLauncher: " << e.cause(); + return; + } // ignore packs without a published version if(pack.versions.length() == 0) continue; diff --git a/application/pages/modplatform/atlauncher/AtlModel.h b/application/pages/modplatform/atlauncher/AtlListModel.h similarity index 100% rename from application/pages/modplatform/atlauncher/AtlModel.h rename to application/pages/modplatform/atlauncher/AtlListModel.h diff --git a/application/pages/modplatform/atlauncher/AtlPage.h b/application/pages/modplatform/atlauncher/AtlPage.h index 368de666f..715cf5f47 100644 --- a/application/pages/modplatform/atlauncher/AtlPage.h +++ b/application/pages/modplatform/atlauncher/AtlPage.h @@ -16,7 +16,7 @@ #pragma once #include "AtlFilterModel.h" -#include "AtlModel.h" +#include "AtlListModel.h" #include