Skip to content

Commit

Permalink
Adding another try-catch to GetLocalizedServerStatus, just in case
Browse files Browse the repository at this point in the history
  • Loading branch information
FelisDiligens committed Oct 26, 2022
1 parent d6880eb commit 7be4fbe
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions Fo76ini/Forms/FormMain/Views/UserControlHome.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<string>();
if (statusKeys[statusKey] != null)
return statusKeys[statusKey].ToObject<string>();

return statusKey;
return statusKey;
}
catch (Exception) // Newtonsoft.Json.JsonReaderException
{
return statusKey;
}
}

return statusKey;
Expand Down

0 comments on commit 7be4fbe

Please sign in to comment.