From 7be4fbe640de66467b3e30fb2fab4e448e5447ec Mon Sep 17 00:00:00 2001 From: FelisDiligens <47528453+FelisDiligens@users.noreply.github.com> Date: Wed, 26 Oct 2022 07:32:35 +0200 Subject: [PATCH] Adding another try-catch to GetLocalizedServerStatus, just in case --- .../Forms/FormMain/Views/UserControlHome.cs | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/Fo76ini/Forms/FormMain/Views/UserControlHome.cs b/Fo76ini/Forms/FormMain/Views/UserControlHome.cs index 0a6446d..2492a0c 100644 --- a/Fo76ini/Forms/FormMain/Views/UserControlHome.cs +++ b/Fo76ini/Forms/FormMain/Views/UserControlHome.cs @@ -369,18 +369,25 @@ private String GetLocalizedServerStatus(String language, String statusKey) if (request.Success && request.StatusCode == HttpStatusCode.OK) { - JObject responseJSON = request.GetJObject(); - JObject statusKeys = (JObject)responseJSON["statusKey"]; + try + { + JObject responseJSON = request.GetJObject(); + JObject statusKeys = (JObject)responseJSON["statusKey"]; - // If translation does not exist, the server returns an empty JSON object {} - // In this situation, fallback to English: - if (statusKeys == null) - return GetLocalizedServerStatus("en", statusKey); + // If translation does not exist, the server returns an empty JSON object {} + // In this situation, fallback to English: + if (statusKeys == null) + return GetLocalizedServerStatus("en", statusKey); - if (statusKeys[statusKey] != null) - return statusKeys[statusKey].ToObject(); + if (statusKeys[statusKey] != null) + return statusKeys[statusKey].ToObject(); - return statusKey; + return statusKey; + } + catch (Exception) // Newtonsoft.Json.JsonReaderException + { + return statusKey; + } } return statusKey;