Skip to content

AI-1261 Frontend Error Page - #172

Merged
dbarkowsky merged 9 commits into
developfrom
AI-1261
Jun 9, 2026
Merged

AI-1261 Frontend Error Page#172
dbarkowsky merged 9 commits into
developfrom
AI-1261

Conversation

@dbarkowsky

Copy link
Copy Markdown
Collaborator

Summary

AI-1261

Changes

  • Added a React class-component ErrorBoundary that catches unhandled errors thrown by top-level providers (AuthProvider, GroupProvider, QueryClientProvider) and reports them to the backend. Supports up to 3 retry attempts before redirecting the user to the home page, with progressive button label feedback ("Try again" → "Go to home page").
  • Added a RouterErrorPage component registered as the errorElement on the root route, catching errors thrown inside route components (anything under RootLayout) that React Router's internal boundary intercepts before the class ErrorBoundary can. Reports errors to the backend and provides a "Go to home page" button.
  • Added a POST /api/client-errors NestJS endpoint in LoggingModule that accepts structured client error payloads (message, component stack, error stack, page URL, user agent) and writes them to the structured logging pipeline (Loki via AppLoggerService).
  • Created ClientErrorDto and ClientErrorResponseDto with full class-validator decorators and Swagger/OpenAPI documentation.
  • Removed the placeholder HelloWorld component.
  • Added an error illustration image to the RouterErrorPage fallback UI.
  • Added full test coverage: 6 Vitest/RTL tests for ErrorBoundary, 4 for RouterErrorPage, and 3 Jest tests for ClientErrorController.

Testing

  1. Start the full dev stack (Dev: all task or npm run dev:frontend + npm run dev:backend).
  2. Trigger a route-level error by temporarily throwing in any page component (e.g. add throw new Error("test") at the top of UploadPage). Navigate to that route — the RouterErrorPage fallback with the error illustration and "Go to home page" button should appear.
  3. Verify a POST /api/client-errors request was sent from the browser (check the Network tab) with message, errorStack, url, and userAgent fields.
  4. Check the backend logs (Loki or terminal output) for a Client-side error reported structured log entry containing the error details.
  5. Click "Go to home page" — the app should navigate to /.
  6. To test ErrorBoundary, trigger an error above the router (e.g. throw in AuthProvider). The full-screen fallback with retry button should render. Clicking "Try again" twice should change the button label to "Go to home page"; clicking it should redirect to /.
  7. Run npx vitest run src/components/ErrorBoundary.spec.tsx src/components/RouterErrorPage.spec.tsx from apps/frontend — all 10 tests should pass.
  8. Run npm test -- --testPathPattern=client-error from apps/backend-services — all 3 tests should pass.

Checklist

By submitting this pull request, I acknowledge that I have attempted to meet the following:

  • a self-review of my code
  • commented code particularly in hard-to-understand areas
  • corresponding changes to the documentation where required
  • changes tested to the best of my ability
  • no new errors or non-functional code

@dbarkowsky dbarkowsky self-assigned this May 20, 2026
@dbarkowsky
dbarkowsky marked this pull request as ready for review May 20, 2026 20:57
Comment thread apps/frontend/src/main.tsx Outdated
Comment thread apps/frontend/src/App.tsx

@kmandryk kmandryk left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Good to go - the error boundary issue is minor, I'll leave that up to you to address or not.

@dbarkowsky
dbarkowsky merged commit 0f5ab25 into develop Jun 9, 2026
12 checks passed
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