Problem
src/components/ErrorBoundary.tsx catches render errors in componentDidCatch and only calls console.error("[ErrorBoundary]", error, info.componentStack). In production this means a crash that takes out part of the UI is invisible to the team: there is no structured logging, no reporting hook, and the raw error is written to the end user's console.
What needs to be done
- Route caught errors through a small reporting abstraction (a function/hook) so a real reporting backend can be plugged in later, defaulting to a no-op or structured console call in development.
- Include useful context (component stack, route) in the report.
- Avoid leaking internal error details to the end-user console in production builds; keep the user-facing fallback UI.
- Ensure the abstraction is easy to mock in tests.
Files
src/components/ErrorBoundary.tsx
- new
src/services/reporting.ts (or similar)
Acceptance deliverables
- Caught errors are sent to a pluggable reporting hook with context, not just
console.error.
- Production builds do not dump raw error details to the user console.
- All CI checks pass; the change cannot be merged until CI is green.
Tests to pass
- Test: when a child throws, the reporting hook is invoked with the error and component stack (hook mocked).
- Test: the fallback UI still renders after an error.
Problem
src/components/ErrorBoundary.tsxcatches render errors incomponentDidCatchand only callsconsole.error("[ErrorBoundary]", error, info.componentStack). In production this means a crash that takes out part of the UI is invisible to the team: there is no structured logging, no reporting hook, and the raw error is written to the end user's console.What needs to be done
Files
src/components/ErrorBoundary.tsxsrc/services/reporting.ts(or similar)Acceptance deliverables
console.error.Tests to pass