-
Notifications
You must be signed in to change notification settings - Fork 0
Mrc-6813: Add Error page for fallback #23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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.svelteas a fallback error boundary that displays status codes, user-friendly messages, and navigation options - Implemented
handleErrorhook inhooks.server.tsto 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 Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
src/routes/+error.svelte
Outdated
| 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.' | ||
| }; |
There was a problem hiding this comment.
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 }?
…ingle object for improved clarity
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-nto see error page.