summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2020-05-20 02:14:30 -0400
committerJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2020-05-20 02:14:30 -0400
commitc5c30189e43f93c3f3c66207945187a974656c9e (patch)
tree66509ae93a6555b743ca33b76bc9d230389420fb /src
parent518bf7e3f13f10d2ef6ea4f064ecd8d58bf07c49 (diff)
downloadSMAPI-c5c30189e43f93c3f3c66207945187a974656c9e.tar.gz
SMAPI-c5c30189e43f93c3f3c66207945187a974656c9e.tar.bz2
SMAPI-c5c30189e43f93c3f3c66207945187a974656c9e.zip
fix error-handling when patch is called with a null target method (#711)
Diffstat (limited to 'src')
-rw-r--r--src/SMAPI/Framework/ModLoading/RewriteFacades/HarmonyInstanceMethods.cs8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/SMAPI/Framework/ModLoading/RewriteFacades/HarmonyInstanceMethods.cs b/src/SMAPI/Framework/ModLoading/RewriteFacades/HarmonyInstanceMethods.cs
index 78cf25f8..17b6bcd9 100644
--- a/src/SMAPI/Framework/ModLoading/RewriteFacades/HarmonyInstanceMethods.cs
+++ b/src/SMAPI/Framework/ModLoading/RewriteFacades/HarmonyInstanceMethods.cs
@@ -34,6 +34,7 @@ namespace StardewModdingAPI.Framework.ModLoading.RewriteFacades
}
catch (Exception ex)
{
+ // get patch types
var patchTypes = new List<string>();
if (prefix != null)
patchTypes.Add("prefix");
@@ -42,7 +43,12 @@ namespace StardewModdingAPI.Framework.ModLoading.RewriteFacades
if (transpiler != null)
patchTypes.Add("transpiler");
- throw new Exception($"Harmony instance {this.Id} failed applying {string.Join("/", patchTypes)} to method {original.DeclaringType?.FullName}.{original.Name}.", ex);
+ // get original method label
+ string methodLabel = original != null
+ ? $"method {original.DeclaringType?.FullName}.{original.Name}"
+ : "null method";
+
+ throw new Exception($"Harmony instance {this.Id} failed applying {string.Join("/", patchTypes)} to {methodLabel}.", ex);
}
}
}