mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-10 14:44:24 +00:00
Trycatch path->sav factory method
Closes #3512 -- had a bad gen3 save backup causing trouble.
This commit is contained in:
parent
ead7c2d973
commit
978be73b9a
1 changed files with 12 additions and 5 deletions
|
@ -540,12 +540,19 @@ namespace PKHeX.Core
|
|||
/// <returns>An appropriate type of save file for the given data, or null if the save data is invalid.</returns>
|
||||
public static SaveFile? GetVariantSAV(string path)
|
||||
{
|
||||
var data = File.ReadAllBytes(path);
|
||||
var sav = GetVariantSAV(data, path);
|
||||
if (sav == null)
|
||||
// Many things can go wrong with loading save data (file no longer present toc-tou, or bad save layout).
|
||||
try
|
||||
{
|
||||
var data = File.ReadAllBytes(path);
|
||||
var sav = GetVariantSAV(data, path);
|
||||
sav?.Metadata.SetExtraInfo(path);
|
||||
return sav;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine(ex);
|
||||
return null;
|
||||
sav.Metadata.SetExtraInfo(path);
|
||||
return sav;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Creates an instance of a SaveFile using the given save data.</summary>
|
||||
|
|
Loading…
Reference in a new issue