From 389e53a8a024d386f027e3c4e47b42450ca2fe23 Mon Sep 17 00:00:00 2001 From: WerWolv Date: Sun, 21 Aug 2022 23:33:08 +0200 Subject: [PATCH] fix: Net request json parser throwing exceptions --- lib/libimhex/source/helpers/net.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/libimhex/source/helpers/net.cpp b/lib/libimhex/source/helpers/net.cpp index 42c4991d0..9446996a1 100644 --- a/lib/libimhex/source/helpers/net.cpp +++ b/lib/libimhex/source/helpers/net.cpp @@ -167,8 +167,10 @@ namespace hex { setCommonSettings(response, url, timeout); auto responseCode = execute(); - - return Response { responseCode.value_or(0), nlohmann::json::parse(response) }; + if (!responseCode.has_value()) + return Response { 0, { } }; + else + return Response { responseCode.value_or(0), nlohmann::json::parse(response, nullptr, false, true) }; }); }