ErrorBanner component
TheErrorBanner component displays error messages to users in a prominent, dismissible banner at the top of the content area.
Location
Appears below the search bar when errors occur during:- User searches (404 user not found)
- API requests (403 rate limit exceeded)
- Network failures
- Repository or commit fetching errors
Props
The error message text to display
Callback function when user clicks the dismiss (X) button
Usage from App.jsx
error state is not null. Dismissing the banner clears the error state.
Error messages from useGitHub hook
The hook throws specific error messages for different HTTP status codes:- “Usuario no encontrado” - 404 user doesn’t exist
- “Rate limit exceeded” or GitHub’s rate limit message - 403 rate limited
- Generic HTTP errors with status code
Implementation details
Source:src/components/ErrorBanner.jsx
Structure:
fade-up class for a smooth entrance animation
Icons:
AlertTriangle(16px) - Warning indicatorX(14px) - Dismiss button
Styling
The banner is styled to stand out with:- Warning colors (typically orange/red background)
- Prominent positioning at the top of the content area
- Flexbox layout for icon, message, and dismiss button alignment
- Hover state on dismiss button
Error handling workflow
- User performs an action (search, pagination, view commits)
- API request fails with an error
- Error is caught in try-catch and set to error state
- ErrorBanner renders with the error message
- User reads the error and clicks dismiss
- Error state is cleared, banner disappears
Related components
Error Handling
Learn about error handling patterns in GitScope
useGitHub Hook
API hook that throws errors caught by ErrorBanner