Skip to content

Report ErrorBoundary-caught errors through a logging/reporting hook #38

Description

@priscaenoch

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.

Metadata

Metadata

Assignees

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardThird CampaignCampaign: Third CampaignenhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions