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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user