debug(combat): explicit error catch + null-check logging

If the CombatStatsTracker constructor throws (e.g. TypeInitializationException
from static field initializers), we now catch and print the exact exception
type + message + inner exception to the DECAL chat window.

Also logs "tracker=OK" or "tracker=NULL" in LoginComplete so we can see
if the object was created at all.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Erik 2026-04-12 10:00:36 +02:00
parent 77e87484e8
commit 11969fc590
2 changed files with 11 additions and 1 deletions

View file

@ -349,7 +349,16 @@ namespace MosswartMassacre
_vitalSharingTracker = new VitalSharingTracker(this);
// Initialize combat stats tracker (Mag-Tools style combat parsing)
_combatStatsTracker = new CombatStatsTracker(this);
try
{
_combatStatsTracker = new CombatStatsTracker(this);
}
catch (Exception combatEx)
{
WriteToChat($"[CombatStats] FATAL: Failed to create tracker: {combatEx.GetType().Name}: {combatEx.Message}");
if (combatEx.InnerException != null)
WriteToChat($"[CombatStats] Inner: {combatEx.InnerException.GetType().Name}: {combatEx.InnerException.Message}");
}
// Initialize command router
_commandRouter = new CommandRouter();
@ -547,6 +556,7 @@ namespace MosswartMassacre
_staticRareTracker = _rareTracker;
_chatEventRouter.SetRareTracker(_rareTracker);
_chatEventRouter.SetCombatTracker(_combatStatsTracker);
WriteToChat($"[CombatStats] tracker={(_combatStatsTracker != null ? "OK" : "NULL")}");
// Apply the values
_rareTracker.RareMetaEnabled = PluginSettings.Instance.RareMetaEnabled;