Skip to content

Conversation

@absternator
Copy link
Contributor

@absternator absternator commented Nov 12, 2025

This PR adds some extra error handling. It mainly adds the +error.svelte, which is an error boundary page that gets hit if there is an error during the load function.(can read more here. Also ive added some logic in hooks.server.ts, this catches any unexpected errors and forwards them on logging the issue.(can read here)

Testing:
spin up app and head to random page etc /projects/wtf-random-n to see error page.

image image

@absternator absternator requested review from M-Kusumgar and Copilot and removed request for Copilot November 12, 2025 15:01
@absternator absternator changed the title feat: add error handling and display for non-existent regions and server errors Mrc-6813: Add Error page for fallback Nov 12, 2025
@absternator absternator requested a review from Copilot November 12, 2025 15:07
Copilot finished reviewing on behalf of absternator November 12, 2025 15:08
Copy link
Contributor

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 implements comprehensive error handling by adding a custom error boundary page (+error.svelte) and enhancing server-side error logging in hooks.server.ts. The error page provides a user-friendly interface for common HTTP errors, while the handleError hook logs detailed error information with unique error IDs for support tracking.

Key Changes:

  • Added +error.svelte as a fallback error boundary that displays status codes, user-friendly messages, and navigation options
  • Implemented handleError hook in hooks.server.ts to log errors with unique IDs and return sanitized messages for 500 errors
  • Added comprehensive test coverage for both the error page component and the server hooks

Reviewed Changes

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

Show a summary per file
File Description
src/routes/+error.svelte Error boundary component with status-specific messages and navigation actions
src/hooks.server.ts Added handleError hook for centralized error logging with unique error IDs
src/tests/routes/error.svelte.spec.ts Unit tests for error page component rendering
src/tests/hooks.server.spec.ts Unit tests for handle and handleError hook functions
e2e/region.test.ts E2E test verifying error page displays for non-existent regions

@codecov
Copy link

codecov bot commented Nov 12, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.67%. Comparing base (d4092e3) to head (17030ca).
⚠️ Report is 8 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #23      +/-   ##
==========================================
- Coverage   97.04%   96.67%   -0.38%     
==========================================
  Files          60       61       +1     
  Lines        2234     2255      +21     
  Branches      493      495       +2     
==========================================
+ Hits         2168     2180      +12     
- Misses         65       74       +9     
  Partials        1        1              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment on lines 5 to 17
const statusMessages: Record<number, string> = {
404: 'Resource Not Found',
500: 'Internal Server Error',
403: 'Forbidden',
401: 'Unauthorized'
};
const statusDescriptions: Record<number, string> = {
404: "The page you're looking for doesn't exist or has been moved.",
500: "Something went wrong on our end. We're working to fix it.",
403: "You don't have permission to access this resource.",
401: 'You need to be authenticated to access this page.'
};
Copy link
Contributor

Choose a reason for hiding this comment

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

perhaps putting these together as one object? so its error code to { message, description }?

Base automatically changed from mrc-6813-e2e-tests to main November 19, 2025 08:29
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.

3 participants