Skip to content

Commit e80e08f

Browse files
committed
Add AutoPatch error interception
1 parent ade21a0 commit e80e08f

1 file changed

Lines changed: 15 additions & 8 deletions

File tree

src/Plugins/CSPlugin.cs

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -134,17 +134,24 @@ public override void HandleAddedToManager(PluginManager manager)
134134
continue;
135135
}
136136

137-
List<MethodInfo> harmonyMethods = HarmonyInstance.CreateClassProcessor(nestedType)?.Patch();
138-
139-
if (harmonyMethods == null || harmonyMethods.Count == 0)
137+
try
140138
{
141-
Interface.Oxide.LogWarning($"[{Title}] AutoPatch attribute found on '{nestedType.Name}' but no HarmonyPatch methods found. Skipping.");
142-
continue;
143-
}
139+
List<MethodInfo> harmonyMethods = HarmonyInstance.CreateClassProcessor(nestedType)?.Patch();
144140

145-
foreach (MethodInfo method in harmonyMethods)
141+
if (harmonyMethods == null || harmonyMethods.Count == 0)
142+
{
143+
Interface.Oxide.LogWarning($"[{Title}] AutoPatch attribute found on '{nestedType.Name}' but no HarmonyPatch methods found. Skipping.");
144+
continue;
145+
}
146+
147+
foreach (MethodInfo method in harmonyMethods)
148+
{
149+
Interface.Oxide.LogInfo($"[{Title}] Automatically Harmony patched '{method.Name}' method. ({nestedType.Name})");
150+
}
151+
}
152+
catch (Exception ex)
146153
{
147-
Interface.Oxide.LogInfo($"[{Title}] Automatically Harmony patched '{method.Name}' method. ({nestedType.Name})");
154+
Interface.Oxide.LogException($"[{Title}] Failed to automatically Harmony patch '{nestedType.Name}'", ex);
148155
}
149156
}
150157

0 commit comments

Comments
 (0)