fix: replace silent error swallowing with console.warn and user-facing error messages

All empty catch blocks across 8 Vue pages now log warnings. User-initiated
actions (fight, matchmake) also surface errors in the UI via fightError/loadError refs.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Dorian
2026-03-07 23:49:45 +00:00
co-authored by Claude Opus 4.6
parent a4008bcf88
commit c98007e95c
8 changed files with 81 additions and 21 deletions
+36 -10
View File
@@ -192,7 +192,9 @@ async function loadFight(): Promise<string | null> {
}
return data.status
}
} catch { /* */ }
} catch (err) {
console.warn('[FightPage] loadFight failed:', err)
}
return null
}
@@ -254,7 +256,9 @@ async function pollForChallenge() {
} else if (humanSubmitted.value) {
humanChallenge.value = null
}
} catch { /* */ }
} catch (err) {
console.warn('[FightPage] pollForChallenge failed:', err)
}
}
function startTimer() {
@@ -287,7 +291,9 @@ async function submitHumanAnswer() {
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ answer: humanAnswer.value.trim() }),
})
} catch { /* */ }
} catch (err) {
console.warn('[FightPage] submitHumanAnswer failed:', err)
}
}
// --- Live scene management ---
@@ -350,7 +356,9 @@ function connectSSE() {
color: 'neon-green',
})
scrollLiveLog()
} catch { /* */ }
} catch (err) {
console.warn('[FightPage] SSE round_start parse failed:', err)
}
})
eventSource.addEventListener('human_challenge', async (e) => {
@@ -377,19 +385,25 @@ function connectSSE() {
} else {
applyChallenge(sseData)
}
} catch { /* */ }
} catch (err) {
console.warn('[FightPage] SSE human_challenge failed:', err)
}
})
eventSource.addEventListener('round_end', (e) => {
try {
handleRoundEnd(JSON.parse(e.data))
} catch { /* */ }
} catch (err) {
console.warn('[FightPage] SSE round_end failed:', err)
}
})
eventSource.addEventListener('fight_end', (e) => {
try {
handleFightEnd(JSON.parse(e.data))
} catch { /* */ }
} catch (err) {
console.warn('[FightPage] SSE fight_end failed:', err)
}
})
let sseRetries = 0
@@ -492,7 +506,9 @@ async function handleRoundEnd(data: any) {
botAScore: result.botAScore || 0,
botBScore: result.botBScore || 0,
})
} catch { /* */ }
} catch (err) {
console.warn('[FightPage] playRound animation failed:', err)
}
if (aWon || bWon) {
await liveScene.playTaunt(aWon ? 'a' : 'b')
@@ -679,8 +695,13 @@ async function fightAgain(botId: string) {
await nextTick()
if (liveFightData.value) await initLiveScene()
}
} else {
fightError.value = `Failed to start fight (${res.status})`
}
} catch { /* */ }
} catch (err) {
fightError.value = 'Network error starting fight'
console.warn('[FightPage] fightAgain failed:', err)
}
isRequeueing.value = false
}
@@ -699,8 +720,13 @@ async function matchmake(botId: string) {
fightError.value = ''
window.history.replaceState({}, '', `/arena/${data.fightId}`)
startPolling()
} else {
fightError.value = `Matchmaking failed (${res.status})`
}
} catch { /* */ }
} catch (err) {
fightError.value = 'Network error during matchmaking'
console.warn('[FightPage] matchmake failed:', err)
}
isRequeueing.value = false
}