0
0
mirror of https://github.com/sp-tarkov/installer.git synced 2025-02-13 01:50:46 -05:00

catch deserilization errors

This commit is contained in:
IsWaffle 2025-01-03 12:07:38 -05:00
parent e6eed2b992
commit df6a60286b

View File

@ -33,9 +33,6 @@ public class ReleaseCheckTask : InstallerTaskBase
return Result.FromError("Failed to download release metadata, try clicking the 'Whats this' button below followed by the 'Clear Metadata cache' button"); return Result.FromError("Failed to download release metadata, try clicking the 'Whats this' button below followed by the 'Clear Metadata cache' button");
} }
var SPTReleaseInfo =
JsonConvert.DeserializeObject<ReleaseInfo>(File.ReadAllText(SPTReleaseInfoFile.FullName));
SetStatus("Checking for Patches", "", null, ProgressStyle.Indeterminate); SetStatus("Checking for Patches", "", null, ProgressStyle.Indeterminate);
var SPTPatchMirrorsFile = var SPTPatchMirrorsFile =
@ -47,12 +44,19 @@ public class ReleaseCheckTask : InstallerTaskBase
return Result.FromError("Failed to download patch mirror data, try clicking the 'Whats this' button below followed by the 'Clear Metadata cache' button"); return Result.FromError("Failed to download patch mirror data, try clicking the 'Whats this' button below followed by the 'Clear Metadata cache' button");
} }
var patchMirrorInfo = ReleaseInfo? SPTReleaseInfo;
JsonConvert.DeserializeObject<PatchInfo>(File.ReadAllText(SPTPatchMirrorsFile.FullName)); PatchInfo? patchMirrorInfo;
if (SPTReleaseInfo == null || patchMirrorInfo == null) try
{ {
return Result.FromError("An error occurred while deserializing SPT or patch data, try clicking the 'Whats this' button below followed by the 'Clear Metadata cache' button"); SPTReleaseInfo = JsonConvert.DeserializeObject<ReleaseInfo>(File.ReadAllText(SPTReleaseInfoFile.FullName));
patchMirrorInfo =
JsonConvert.DeserializeObject<PatchInfo>(File.ReadAllText(SPTPatchMirrorsFile.FullName));
}
catch (Exception ex)
{
return Result.FromError($"An error occurred while deserializing SPT or patch data, try clicking the 'Whats this' button below followed by the 'Clear Metadata cache' button.\n\nERROR: {ex.Message}");
} }
_data.ReleaseInfo = SPTReleaseInfo; _data.ReleaseInfo = SPTReleaseInfo;