Skip to content

Add error boundary components for error handling#107

Open
MarcosBrendonDePaula wants to merge 2 commits intomainfrom
claude/implement-pending-issue-TqNm1
Open

Add error boundary components for error handling#107
MarcosBrendonDePaula wants to merge 2 commits intomainfrom
claude/implement-pending-issue-TqNm1

Conversation

@MarcosBrendonDePaula
Copy link
Copy Markdown
Collaborator

Summary

Introduces comprehensive error handling to the application through two new error boundary components: a general-purpose ErrorBoundary and a specialized LiveErrorBoundary for real-time components. These boundaries catch React component errors and display user-friendly fallback UI while providing recovery mechanisms.

Key Changes

  • ErrorBoundary component: A reusable error boundary that catches component errors with support for:

    • Custom fallback UI (ReactNode or function-based)
    • Error callback hooks for logging/monitoring
    • Reset functionality to recover from errors
    • Default fallback UI with error details in development mode
  • LiveErrorBoundary component: A specialized error boundary for live/real-time components with:

    • Live-specific error messaging and styling
    • "Reconnect" button instead of generic "Try again"
    • Tailored for WebSocket-based components
  • Application integration:

    • Wraps root app with ErrorBoundary in main.tsx for global error handling
    • Wraps all live demo components with LiveErrorBoundary for targeted error recovery
  • Test coverage: Comprehensive unit tests covering:

    • Normal rendering without errors
    • Default and custom fallback UI
    • Error callback invocation
    • Reset/recovery functionality
    • Both ErrorBoundary and LiveErrorBoundary variants
  • Build configuration: Updated Vitest config to include .test.tsx files

Implementation Details

  • Uses React's class component API for error boundary implementation (required for getDerivedStateFromError and componentDidCatch)
  • Provides flexible fallback patterns: static ReactNode, function-based with error/reset parameters, or default UI
  • Development mode shows detailed error information; production shows user-friendly messages
  • Styled with Tailwind CSS for consistent visual hierarchy (red for critical errors, amber for live component issues)

https://claude.ai/code/session_01HRT3EReuYwLui8J8RTJhwW

claude added 2 commits April 4, 2026 01:37
Prevent rendering errors from crashing the entire application by adding
Error Boundary components with user-friendly fallback UIs.

- Generic ErrorBoundary with customizable fallback and error callback
- LiveErrorBoundary specialized for Live Components with reconnect UX
- Top-level ErrorBoundary in main.tsx catches any unhandled render error
- All Live Component routes wrapped with LiveErrorBoundary
- Dev mode shows error details, production shows clean message

https://claude.ai/code/session_01HRT3EReuYwLui8J8RTJhwW
9 tests covering: default fallback, custom fallbacks, onError callback,
reset/recovery flow, and LiveErrorBoundary specialized behavior.
Also adds .tsx to vitest include pattern so JSX tests can run.

https://claude.ai/code/session_01HRT3EReuYwLui8J8RTJhwW
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