Skip to content

Route all fatal errors through a single shutdown handler#46

Merged
maximmaxim345 merged 4 commits intomainfrom
fix/error-message
Mar 31, 2026
Merged

Route all fatal errors through a single shutdown handler#46
maximmaxim345 merged 4 commits intomainfrom
fix/error-message

Conversation

@maximmaxim345
Copy link
Copy Markdown
Member

Previously, several fatal failure paths (reconnect exhaustion, Cast framework errors, global JS errors, unhandled rejections) each had their own ad-hoc handling. They are now routed through a single handleFatalError function that reports the error state to the sender, shows it on screen, and shuts down the app.

Also adds ensureAudioContextSupported and wraps SendspinPlayer construction in a try/catch so setup failures on unsupported devices are caught and reported the same way.

@maximmaxim345 maximmaxim345 requested a review from Copilot March 9, 2026 12:32
@maximmaxim345 maximmaxim345 added the maintenance This PR does maintenance on the Code label Mar 9, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR consolidates all fatal error paths in the Cast receiver into a single handleFatalError function, eliminating ad-hoc handling across multiple code paths. It also adds ensureAudioContextSupported() and wraps SendspinPlayer construction in a try/catch to catch setup failures on unsupported devices.

Changes:

  • Adds handleFatalError(context, error, summary) as a single unified shutdown handler with idempotency guard, and refactors all fatal error paths (reconnect exhaustion, Cast framework errors, global JS errors, unhandled rejections) to route through it
  • Adds ensureAudioContextSupported() and a try/catch around SendspinPlayer construction in connectToServer to properly handle device capability failures
  • Updates README.md with a new "Error Handling" section documenting the fatal vs. non-fatal error distinction

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/js/main.ts Core refactor: adds handleFatalError, toErrorMessage, ensureAudioContextSupported; moves and routes all fatal error handlers through the new unified path
README.md Adds "Error Handling" documentation section describing the fatal/non-fatal behavior

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/js/main.ts Outdated
Comment thread src/js/main.ts Outdated
maximmaxim345 added a commit to maximmaxim345/cast that referenced this pull request Mar 30, 2026
Return false from window.onerror to preserve browser default error
reporting, and fix log prefix to match "Sendspin: ..." convention.
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/js/main.ts Outdated
Comment thread src/js/main.ts
Non-Error values like Cast framework events rendered as
[object Object] on screen.
@maximmaxim345 maximmaxim345 merged commit ea4fcec into main Mar 31, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintenance This PR does maintenance on the Code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants