fix: wrap mulligan message creation in try/catch to prevent handler abort

Even with the partial correctly registered, a template rendering failure
should not abort the entire reroll handler. Without try/catch, the
exception propagates out of the do-while loop and prevents combat result
creation. The reroll value was applied but nothing else happened.
This commit is contained in:
2026-07-05 20:51:26 +02:00
parent 881cecf5b7
commit bfbce9557b
2 changed files with 43 additions and 31 deletions
+15 -11
View File
@@ -206,17 +206,21 @@ export async function handleAttackBoosted(msg) {
if (!reroll) continue
updatedDefenseRoll = reroll.options?.rollTotal || reroll.total || oldDefenseRoll
let newD30message = reroll.options?.D30message || null
const mulliganContent = await foundry.applications.handlebars.renderTemplate("systems/fvtt-lethal-fantasy/templates/chat/reaction-message.hbs", {
type: "mulligan",
actorName: defenderName,
side: "defense",
oldRoll: oldDefenseRoll,
newRoll: updatedDefenseRoll,
diceResults: reroll.options?.diceResults || [],
D30result: reroll.options?.D30result,
D30message: newD30message
})
await ChatMessage.create({content: mulliganContent, speaker: ChatMessage.getSpeaker({actor: defender})})
try {
const mulliganContent = await foundry.applications.handlebars.renderTemplate("systems/fvtt-lethal-fantasy/templates/chat/reaction-message.hbs", {
type: "mulligan",
actorName: defenderName,
side: "defense",
oldRoll: oldDefenseRoll,
newRoll: updatedDefenseRoll,
diceResults: reroll.options?.diceResults || [],
D30result: reroll.options?.D30result,
D30message: newD30message
})
await ChatMessage.create({content: mulliganContent, speaker: ChatMessage.getSpeaker({actor: defender})})
} catch(e) {
console.error("Mulligan message creation failed (non-fatal):", e)
}
// Process new D30 bonus dice from the reroll
if (newD30message) {
defenseD30message = newD30message