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
|
let d30AttackPrecomputedStale = false
|
||||||
|
|
||||||
do {
|
do {
|
||||||
|
try {
|
||||||
mulliganRestart = false
|
mulliganRestart = false
|
||||||
defenderHandledBonus = false
|
defenderHandledBonus = false
|
||||||
attackerHandledBonus = false
|
attackerHandledBonus = false
|
||||||
@@ -829,6 +830,10 @@ Hooks.on("createChatMessage", async (message) => {
|
|||||||
mulliganRestart = true
|
mulliganRestart = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch(e) {
|
||||||
|
console.error("Defense handler loop error (non-fatal):", e)
|
||||||
|
mulliganRestart = false
|
||||||
|
}
|
||||||
} while (mulliganRestart)
|
} while (mulliganRestart)
|
||||||
|
|
||||||
const shieldDamageReduction = shieldBlocked ? shieldReaction?.damageReduction ?? 0 : 0
|
const shieldDamageReduction = shieldBlocked ? shieldReaction?.damageReduction ?? 0 : 0
|
||||||
|
|||||||
Reference in New Issue
Block a user