Skip to content

Comments

Feat implement global error handling#82

Merged
BrayanMQ merged 4 commits intomainfrom
feat-implement-global-error-handling
Jan 11, 2026
Merged

Feat implement global error handling#82
BrayanMQ merged 4 commits intomainfrom
feat-implement-global-error-handling

Conversation

@BrayanMQ
Copy link
Owner

📝 Description

This PR implements a comprehensive global error handling system for the application. It includes a React Error Boundary for catching component-level crashes, Next.js error pages for route-level failures, centralized error utilities, and real-time network status monitoring with user feedback.

🔗 Related Issue

Closes #27

🏷️ Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)
  • Performance improvement
  • Dependency update

🔄 Changes Made

  • Error Boundary Components: Created ErrorBoundary and ErrorFallback in components/errors/ to catch JavaScript errors and display a consistent UI with retry/reset capabilities.
  • Next.js Error Pages: Implemented app/error.tsx and app/global-error.tsx to handle runtime errors at both the route segment and root layout levels.
  • Centralized Error Utilities: Added lib/errors.ts for parsing Supabase errors, detecting network/offline states, and providing development-mode logging.
  • Network Status Monitoring: Created NetworkStatusProvider to monitor navigator.onLine and show toast notifications when the connection is lost or restored.
  • Internationalization: Added comprehensive error translations in en.json and es.json for all new components and scenarios.
  • App Integration: Integrated the new providers and boundaries into the root Providers component and app structure.

🧪 Testing

  • Manual testing completed (Verified Error Boundary by manually throwing errors, verified Offline/Online toasts via browser DevTools).
  • Unit tests added/updated
  • Integration tests added/updated
  • Verified production build (npm run build).

✅ Checklist

  • My code follows the project's code style guidelines
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have updated the documentation accordingly (if applicable)
  • My changes generate no new warnings
  • New and existing unit tests pass locally with my changes

📸 Screenshots (if applicable)

(Screenshots of the ErrorFallback and Network Toasts should be added here)

📌 Additional Notes

The global-error.tsx uses inline styles as a failsafe because it might be triggered when Tailwind or other CSS providers fail to load. In development mode, detailed error messages and stack traces are displayed to facilitate debugging.

…or handling

- Introduced ErrorBoundary component to catch JavaScript errors in child components and display a fallback UI.
- Added ErrorFallback component for user-friendly error display, featuring a clean design and options to reset the error state or navigate to the dashboard.
- Implemented higher-order component `withErrorBoundary` to wrap components with error handling capabilities.
- Updated index file to export the new components for easy access.
… components

- Added Error component for handling runtime errors at the route segment level, featuring a user-friendly UI and reset functionality.
- Introduced GlobalError component as a catch-all error boundary for critical errors in the root layout, ensuring a consistent user experience across the application.
- Created a centralized errors utility module for structured error handling, including functions for categorizing and logging errors, as well as parsing Supabase errors into user-friendly messages.
- Introduced NetworkStatusProvider component to monitor the browser's online/offline status and provide context to child components.
- Implemented useNetworkStatus hook for easy access to network status.
- Added toast notifications for network status changes, enhancing user experience.
- Updated English and Spanish localization files with network-related error messages.
- Updated the Providers component to include NetworkStatusProvider, enhancing the app's ability to monitor online/offline status for child components.
@BrayanMQ BrayanMQ linked an issue Jan 11, 2026 that may be closed by this pull request
@BrayanMQ BrayanMQ merged commit 61ae074 into main Jan 11, 2026
1 check passed
@BrayanMQ BrayanMQ deleted the feat-implement-global-error-handling branch January 11, 2026 17:03
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.

Implement global error handling

1 participant