Skip to content

Commit f9c40a0

Browse files
committed
put the Harmony patcher in a try/catch
1 parent c8d829d commit f9c40a0

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

Source/Shabby.cs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,19 @@ private void Awake()
8080
harmony = new Harmony("Shabby");
8181
Log.Message("Harmony patching");
8282
foreach (var type in Assembly.GetExecutingAssembly().GetTypes()) {
83-
PatchClassProcessor processor = new(harmony, type);
84-
if (processor.Patch() is not List<MethodInfo> patchedMethods) continue;
85-
if (patchedMethods.Count == 0) {
86-
Log.Message($"`{type.Name}` skipped");
87-
continue;
83+
try {
84+
PatchClassProcessor processor = new(harmony, type);
85+
if (processor.Patch() is not List<MethodInfo> patchedMethods) continue;
86+
if (patchedMethods.Count == 0) {
87+
Log.Message($"`{type.Name}` skipped");
88+
continue;
89+
}
90+
91+
Log.Message(
92+
$"`{type.Name}` patched methods {string.Join(", ", patchedMethods.Select(m => $"`{m.Name}`"))}");
93+
} catch (Exception e) {
94+
Log.Error($"encountered exception while applying `{type.Name}`:\n{e}");
8895
}
89-
90-
Log.Message(
91-
$"`{type.Name}` patched methods {string.Join(", ", patchedMethods.Select(m => $"`{m.Name}`"))}");
9296
}
9397

9498
// Register as an explicit MM callback such that it is run before all reflected

0 commit comments

Comments
 (0)