Skip to content

Commit

Permalink
Catch everything when applying Affinity patches
Browse files Browse the repository at this point in the history
Harmony won't necessarily wrap exceptions in a HarmonyException
  • Loading branch information
nicoco007 committed Nov 16, 2024
1 parent ada953b commit 47dffd4
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions SiraUtil/Affinity/Harmony/HarmonyAffinityPatcher.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using IPA.Loader;
using SiraUtil.Affinity.Harmony.Generator;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
Expand Down Expand Up @@ -76,9 +77,9 @@ public void Patch(IAffinity affinity)
MethodInfo contract = dynamicHarmonyPatchGenerator.Patch(affinity, affinityMethod, patchType, attribute.Complete ? attribute : classAffinityPatch, priority, before, after);
methods.Add(contract);
}
catch (HarmonyLib.HarmonyException ex)
catch (Exception ex)
{
throw new AffinityException($"Failed to execute patch for method '{affinityMethod}' on '{affinityMethod.DeclaringType.FullName}'", ex);
throw new AffinityException($"Failed to execute patch for method '{affinityMethod}' on '{affinityMethod.DeclaringType.FullName}' (assembly '{affinityMethod.DeclaringType.Assembly.GetName().Name}')", ex);
}
}
}
Expand Down

0 comments on commit 47dffd4

Please sign in to comment.