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:
co-authored by
Claude Opus 4.6
parent
a4008bcf88
commit
c98007e95c
@@ -77,6 +77,8 @@ const waitingFighters = ref<QueueEntry[]>([])
|
||||
let pollHandle: ReturnType<typeof setInterval> | null = null
|
||||
|
||||
const isOwner = ref(false)
|
||||
const loadError = ref('')
|
||||
const fightError = ref('')
|
||||
const showCustomize = ref(false)
|
||||
const isSaving = ref(false)
|
||||
const custError = ref('')
|
||||
@@ -207,7 +209,11 @@ onMounted(async () => {
|
||||
try {
|
||||
const res = await fetch(`/api/bots/${encodeURIComponent(botName)}/stats`)
|
||||
if (res.ok) stats.value = await res.json()
|
||||
} catch { /* */ }
|
||||
else loadError.value = `Failed to load bot (${res.status})`
|
||||
} catch (err) {
|
||||
loadError.value = 'Network error loading bot profile'
|
||||
console.warn('[BotProfile] load failed:', err)
|
||||
}
|
||||
isLoading.value = false
|
||||
|
||||
// Check ownership
|
||||
@@ -229,32 +235,46 @@ async function pollQueue() {
|
||||
const data = await res.json()
|
||||
waitingFighters.value = data.queue || []
|
||||
}
|
||||
} catch { /* */ }
|
||||
} catch (err) {
|
||||
console.warn('[BotProfile] queue poll failed:', err)
|
||||
}
|
||||
}
|
||||
|
||||
async function instantFight() {
|
||||
if (!stats.value || isJoining.value) return
|
||||
isJoining.value = true
|
||||
fightError.value = ''
|
||||
try {
|
||||
const res = await fetch(`/api/queue/join/${stats.value.id}`, { method: 'POST' })
|
||||
if (res.ok) {
|
||||
const data = await res.json()
|
||||
router.push(`/arena/${data.fightId}`)
|
||||
} else {
|
||||
fightError.value = `Matchmaking failed (${res.status})`
|
||||
}
|
||||
} catch { /* */ }
|
||||
} catch (err) {
|
||||
fightError.value = 'Network error starting fight'
|
||||
console.warn('[BotProfile] instant fight failed:', err)
|
||||
}
|
||||
isJoining.value = false
|
||||
}
|
||||
|
||||
async function fightSpecific(opponentBotId: string) {
|
||||
if (!stats.value || isJoining.value) return
|
||||
isJoining.value = true
|
||||
fightError.value = ''
|
||||
try {
|
||||
const res = await fetch(`/api/fights/matchmake/${stats.value.id}`, { method: 'POST' })
|
||||
if (res.ok) {
|
||||
const data = await res.json()
|
||||
router.push(`/arena/${data.fightId}`)
|
||||
} else {
|
||||
fightError.value = `Matchmaking failed (${res.status})`
|
||||
}
|
||||
} catch { /* */ }
|
||||
} catch (err) {
|
||||
fightError.value = 'Network error starting fight'
|
||||
console.warn('[BotProfile] fight specific failed:', err)
|
||||
}
|
||||
isJoining.value = false
|
||||
}
|
||||
|
||||
@@ -275,7 +295,7 @@ const tierClass = (t: number) => `tier-${t}`
|
||||
</div>
|
||||
|
||||
<div v-else-if="!stats" class="flex-1 flex items-center justify-center">
|
||||
<p class="font-display text-text-muted">Bot not found.</p>
|
||||
<p class="font-display text-text-muted">{{ loadError || 'Bot not found.' }}</p>
|
||||
</div>
|
||||
|
||||
<template v-else>
|
||||
@@ -426,6 +446,8 @@ const tierClass = (t: number) => `tier-${t}`
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<p v-if="fightError" class="font-mono text-[10px] text-neon-pink mt-2">{{ fightError }}</p>
|
||||
|
||||
<!-- Choose your fight panel -->
|
||||
<div v-if="showChoose" class="mt-3 border border-border bg-surface-raised/50 p-3">
|
||||
<p class="font-display text-[10px] font-bold text-text-muted tracking-[0.15em] mb-2">
|
||||
|
||||
Reference in New Issue
Block a user