SMAPI - Stardew Modding API

SMAPI - Stardew Modding API

971k Downloads

Improve error when mods throw exceptions from event handlers

Pathoschild opened this issue ยท 1 comments

commented

When a mod throws an exception from an event handler, SMAPI shows a message like this:

[SMAPI] A mod failed handling the PlayerEvents.InventoryChanged event:
System.InvalidCastException: Unable to cast object of type 'StardewValley.Tools.MeleeWeapon' to type 'StardewValley.Object'.
at SeasonalItems.ModEntry.PlayerEvents_InventoryChanged(Object sender, EventArgsInventoryChanged e)
at StardewModdingAPI.Framework.InternalExtensions.SafelyRaiseGenericEvent[TEventArgs](IMonitor monitor, String name, IEnumerable`1 handlers, Object sender, TEventArgs args) in C:\source_Stardew\SMAPI\src\SMAPI\Framework\InternalExtensions.cs:line 65

Keep track of the mod which added each event handler, and show a more informative error that doesn't require players to read the stack trace to identify the mod.

commented

Done in develop for the SMAPI 2.5 release.