diff --git a/1.7/Assemblies/BlaxSlaves.dll b/1.7/Assemblies/BlaxSlaves.dll
index 4b55245..34a2985 100644
Binary files a/1.7/Assemblies/BlaxSlaves.dll and b/1.7/Assemblies/BlaxSlaves.dll differ
diff --git a/1.7/Assemblies/BlaxSlaves.pdb b/1.7/Assemblies/BlaxSlaves.pdb
index df99dd1..fcdd4e4 100644
Binary files a/1.7/Assemblies/BlaxSlaves.pdb and b/1.7/Assemblies/BlaxSlaves.pdb differ
diff --git a/About/About.xml b/About/About.xml
index 0bdf021..80573ef 100644
--- a/About/About.xml
+++ b/About/About.xml
@@ -3,7 +3,7 @@
Blax Slaves
Blax Gaming
blax.slaves
- 1.2.1
+ 1.2.2
1.7
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 8bd71fc..9c60fd4 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,9 @@
# Changelog
+## 1.2.2
+
+- Errors from other mods or the game in the hooked methods now keep their full stack trace, so they no longer look like Blax Slaves errors.
+
## 1.2.1
- Works with any DLC combination, core only included. Without Ideology the slave features stay off and their settings show greyed out with a "needs Ideology" note; every trader still buys your prisoners, and the slaver changes still apply.
diff --git a/Source/BlaxSlaves/SlaveHarm.cs b/Source/BlaxSlaves/SlaveHarm.cs
index e9b50ce..c1f43de 100644
--- a/Source/BlaxSlaves/SlaveHarm.cs
+++ b/Source/BlaxSlaves/SlaveHarm.cs
@@ -129,10 +129,9 @@ namespace BlaxSlaves
{
public static void Prefix(Pawn victim, out SlaveHarm.Frame __state) => __state = SlaveHarm.Push(victim);
- public static Exception Finalizer(Exception __exception, SlaveHarm.Frame __state)
+ public static void Finalizer(SlaveHarm.Frame __state)
{
SlaveHarm.Pop(__state);
- return __exception;
}
}
@@ -141,10 +140,9 @@ namespace BlaxSlaves
{
public static void Prefix(Pawn victim, out SlaveHarm.Frame __state) => __state = SlaveHarm.Push(victim);
- public static Exception Finalizer(Exception __exception, SlaveHarm.Frame __state)
+ public static void Finalizer(SlaveHarm.Frame __state)
{
SlaveHarm.Pop(__state);
- return __exception;
}
}
@@ -161,10 +159,9 @@ namespace BlaxSlaves
__state.protectedVictim = false;
}
- public static Exception Finalizer(Exception __exception, SlaveHarm.Frame __state)
+ public static void Finalizer(SlaveHarm.Frame __state)
{
SlaveHarm.Pop(__state);
- return __exception;
}
}
@@ -179,10 +176,9 @@ namespace BlaxSlaves
__state.protectedVictim = false;
}
- public static Exception Finalizer(Exception __exception, SlaveHarm.Frame __state)
+ public static void Finalizer(SlaveHarm.Frame __state)
{
SlaveHarm.Pop(__state);
- return __exception;
}
}
@@ -192,10 +188,9 @@ namespace BlaxSlaves
{
public static void Prefix(Pawn patient, out SlaveHarm.Frame __state) => __state = SlaveHarm.Push(patient);
- public static Exception Finalizer(Exception __exception, SlaveHarm.Frame __state)
+ public static void Finalizer(SlaveHarm.Frame __state)
{
SlaveHarm.Pop(__state);
- return __exception;
}
}
@@ -218,10 +213,9 @@ namespace BlaxSlaves
}
}
- public static Exception Finalizer(Exception __exception, SlaveHarm.Frame __state)
+ public static void Finalizer(SlaveHarm.Frame __state)
{
SlaveHarm.Pop(__state);
- return __exception;
}
}
@@ -256,10 +250,9 @@ namespace BlaxSlaves
soldInGift = queue;
}
- public static Exception Finalizer(Exception __exception, Queue __state)
+ public static void Finalizer(Queue __state)
{
soldInGift = __state;
- return __exception;
}
}
@@ -302,10 +295,9 @@ namespace BlaxSlaves
}
}
- public static Exception Finalizer(Exception __exception, SlaveHarm.Frame __state)
+ public static void Finalizer(SlaveHarm.Frame __state)
{
SlaveHarm.Pop(__state);
- return __exception;
}
}
@@ -343,10 +335,9 @@ namespace BlaxSlaves
public static void Prefix() => depth++;
- public static Exception Finalizer(Exception __exception)
+ public static void Finalizer()
{
depth--;
- return __exception;
}
}
@@ -431,10 +422,9 @@ namespace BlaxSlaves
}
}
- public static Exception FrameFinalizer(Exception __exception, SlaveHarm.Frame __state)
+ public static void FrameFinalizer(SlaveHarm.Frame __state)
{
SlaveHarm.Pop(__state);
- return __exception;
}
public static void NotPendingPostfix(Pawn pawn, ref bool __result)
diff --git a/Tests/BlaxSlavesTests/Source/SmokeTests.cs b/Tests/BlaxSlavesTests/Source/SmokeTests.cs
index b72bc65..ed61356 100644
--- a/Tests/BlaxSlavesTests/Source/SmokeTests.cs
+++ b/Tests/BlaxSlavesTests/Source/SmokeTests.cs
@@ -28,6 +28,22 @@ namespace BlaxSlavesTests
T.Check(warnings.Count == 0, "warnings mentioning Blax Slaves at startup: " + string.Join(" | ", warnings.Take(3).Select(e => e.text)));
}
+ [BlaxTest("startup: every Blax Slaves finalizer returns void, so Harmony rethrows exceptions with their stack trace")]
+ public static void FinalizersReturnVoid()
+ {
+ // One finalizer returning Exception on a method makes Harmony "throw ex" instead of "rethrow"
+ // (0Harmony EmitFinalizers), which cuts the inner frames off every exception passing through it.
+ var finalizers = Harmony.GetAllPatchedMethods()
+ .Select(Harmony.GetPatchInfo)
+ .Where(info => info != null)
+ .SelectMany(info => info.Finalizers)
+ .Where(p => p.owner == "blax.slaves")
+ .ToList();
+ T.Check(finalizers.Count >= 9, "Blax Slaves finalizers found: " + finalizers.Count + ", expected at least 9");
+ var bad = finalizers.Where(p => p.PatchMethod.ReturnType != typeof(void)).Select(p => p.PatchMethod.DeclaringType?.Name + "." + p.PatchMethod.Name).ToList();
+ T.Check(bad.Count == 0, "finalizers that return a value: " + string.Join(", ", bad));
+ }
+
[BlaxTest("startup: settings and defs loaded")]
public static void DefsLoaded()
{