diff --git a/app.js b/app.js index 1cfc8ca..54b9f86 100644 --- a/app.js +++ b/app.js @@ -65,9 +65,9 @@ window.clearTeams = clearSelections; window.filterPlayers = filterPlayerList; -window.recordMatch = recordMatch; -window.recordDoublesMatch = recordDoublesMatch; -window.addPlayer = addPlayer; +window.recordMatch = () => recordMatch().catch(err => showError(err.message)); +window.recordDoublesMatch = () => recordDoublesMatch().catch(err => showError(err.message)); +window.addPlayer = () => addPlayer().catch(err => showError(err.message)); // ================= INITIALISIERUNG ================= @@ -81,6 +81,7 @@ window.onload = async function() { if (!_cfg.SUPABASE_URL || !_cfg.SUPABASE_ANON_KEY) { showError('Supabase nicht konfiguriert. Bitte config.js anlegen (siehe config.example.js).'); + return; } await loadPlayers(); @@ -325,6 +326,7 @@ async function saveMatch(match, playerEntries) { await Promise.all(playerEntries.map(({ id }) => updatePlayer(id, state.players[id]))); } catch (revertErr) { console.error('ELO-Revert fehlgeschlagen:', revertErr); + showError('ELO-Synchronisation fehlgeschlagen. Bitte Seite neu laden.'); } showError('Fehler beim Speichern. Match wurde nicht übertragen.'); } finally { diff --git a/src/ui.js b/src/ui.js index d79e9b1..e9d7ff1 100644 --- a/src/ui.js +++ b/src/ui.js @@ -16,6 +16,7 @@ export function getAvatarEmoji(playerId) { export function showError(message) { const el = document.getElementById('errorMessage'); + if (!el) { console.error(message); return; } el.textContent = message; el.style.display = 'block'; setTimeout(() => { el.style.display = 'none'; }, 5000); @@ -23,6 +24,7 @@ export function showError(message) { export function showSuccess(message) { const el = document.getElementById('successMessage'); + if (!el) { console.log(message); return; } el.textContent = message; el.style.display = 'block'; setTimeout(() => { el.style.display = 'none'; }, 5000);