From d17c9cba494a8851206e5758a5d8e4e6c7bdbb82 Mon Sep 17 00:00:00 2001 From: LeRatierBretonnier Date: Sun, 5 Jul 2026 20:55:29 +0200 Subject: [PATCH] fix: wrap do-while loop body in try/catch to protect against exceptions Any exception from createReactionMessage or renderTemplate inside the defense/attack reaction loops would silently abort the handler, preventing combat result creation. The try/catch logs the error and continues safely. --- module/hooks/chat-reaction.mjs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/module/hooks/chat-reaction.mjs b/module/hooks/chat-reaction.mjs index ff10df5..1fc7c8d 100644 --- a/module/hooks/chat-reaction.mjs +++ b/module/hooks/chat-reaction.mjs @@ -466,6 +466,7 @@ Hooks.on("createChatMessage", async (message) => { let d30AttackPrecomputedStale = false do { + try { mulliganRestart = false defenderHandledBonus = false attackerHandledBonus = false @@ -829,6 +830,10 @@ Hooks.on("createChatMessage", async (message) => { mulliganRestart = true } } + } catch(e) { + console.error("Defense handler loop error (non-fatal):", e) + mulliganRestart = false + } } while (mulliganRestart) const shieldDamageReduction = shieldBlocked ? shieldReaction?.damageReduction ?? 0 : 0