diff --git a/Libraries/SPTarkov.Server.Core/Services/ProfileMigratorService.cs b/Libraries/SPTarkov.Server.Core/Services/ProfileMigratorService.cs index 9954a34b..e174d27e 100644 --- a/Libraries/SPTarkov.Server.Core/Services/ProfileMigratorService.cs +++ b/Libraries/SPTarkov.Server.Core/Services/ProfileMigratorService.cs @@ -37,7 +37,7 @@ public class ProfileMigratorService( ) { return profile.Deserialize(JsonUtil.JsonSerializerOptionsNoIndent) - ?? throw new InvalidOperationException($"Could not deserialize the profile {profileId}"); + ?? throw new InvalidOperationException($"Could not deserialize the profile: {profileId}"); } var ranMigrations = new List(); @@ -59,9 +59,27 @@ public class ProfileMigratorService( } } - var sptReadyProfile = - profile.Deserialize(JsonUtil.JsonSerializerOptionsNoIndent) - ?? throw new InvalidOperationException($"Could not deserialize the profile {profileId}"); + SptProfile sptReadyProfile; + + try + { + sptReadyProfile = + profile.Deserialize(JsonUtil.JsonSerializerOptionsNoIndent) + ?? throw new InvalidOperationException($"Could not deserialize the profile."); + } + catch (Exception ex) + { + logger.Critical($"Could not load profile: {profileId}"); + logger.Critical(ex.ToString()); + + if (ex.StackTrace is not null) + { + logger.Critical(ex.StackTrace); + } + + // Throw here, immediately stops execution of the server upon detecting a messed up profile + throw; + } foreach (var ranMigration in ranMigrations) {