Skip to content

fix: harden error handling and prevent uncaught async rejections#27

Merged
daimpad merged 1 commit into
mainfrom
fix/code-review-3
Jun 7, 2026
Merged

fix: harden error handling and prevent uncaught async rejections#27
daimpad merged 1 commit into
mainfrom
fix/code-review-3

Conversation

@daimpad

@daimpad daimpad commented Jun 7, 2026

Copy link
Copy Markdown
Owner

$(cat <<'EOF'

Summary

  • Null guards in showError/showSuccess — if the DOM elements are absent (e.g. during tests), errors are routed to console.error/console.log instead of throwing
  • Early return on missing Supabase configloadPlayers/loadMatches are no longer called with empty credentials; the error message is shown and the app stops gracefully
  • ELO revert failure surfaced to user — when the catch-block revert write fails, showError is called in addition to console.error so the user knows to reload
  • window.* async functions wrapped with .catch — HTML onclick attributes call window.recordMatch etc.; unhandled promise rejections are now caught and shown via showError

Test plan

  • All 56 unit tests pass (npm test)
  • Opening app without config.js shows the config error and does not attempt network calls
  • Submitting a match that fails mid-write shows the error toast (manual test / demo mode)
  • No regressions in normal singles/doubles match recording flow

https://claude.ai/code/session_01TgxiTLy7fCh5xZPJT8eTVt
EOF
)


Generated by Claude Code

- Add null guards to showError/showSuccess so tests and pre-DOM calls
  don't throw when message elements are absent
- Return early from onload when Supabase is not configured so
  loadPlayers/loadMatches are never called with empty credentials
- Surface ELO revert failures to the user via showError instead of
  silently logging them
- Wrap window.recordMatch/recordDoublesMatch/addPlayer with .catch so
  unhandled promise rejections from HTML onclick attributes are shown

https://claude.ai/code/session_01TgxiTLy7fCh5xZPJT8eTVt
@daimpad daimpad merged commit 85042ff into main Jun 7, 2026
1 check passed
@daimpad daimpad deleted the fix/code-review-3 branch June 7, 2026 21:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants