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.
This commit is contained in:
2026-07-05 20:55:29 +02:00
parent bfbce9557b
commit d17c9cba49
+5
View File
@@ -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