Skip to content

feat: display friendly error messages on API failure#47

Closed
Ai-chan-0411 wants to merge 2 commits intoO2sa:mainfrom
Ai-chan-0411:feat/friendly-error-messages
Closed

feat: display friendly error messages on API failure#47
Ai-chan-0411 wants to merge 2 commits intoO2sa:mainfrom
Ai-chan-0411:feat/friendly-error-messages

Conversation

@Ai-chan-0411
Copy link
Copy Markdown
Contributor

Summary

Closes #34

Adds user-friendly error messages when the GitHub API fails, replacing generic error text with specific, actionable messages.

Changes

API route (app/api/compare/route.ts)

  • Added classifyError() helper that maps different failure modes to clear messages:
    • User not found (404): "GitHub user not found. Please check the username and try again."
    • Rate limit exceeded (429): "GitHub API rate limit exceeded. Please wait a few minutes and try again."
    • Auth error (401/500): "GitHub API authentication error. Please contact the administrator."
    • Network error (503): "Unable to reach GitHub. Please check your connection and try again."
    • Generic fallback: "Something went wrong while fetching data. Please try again later."
  • Returns appropriate HTTP status codes for each error type

Page (app/page.tsx)

  • Passes error prop to CompareForm component for inline error display
  • Removed duplicate error display below the form (the CompareForm already has a styled Alert for errors)

Before / After

Before After
"Failed to calculate score" "GitHub user not found. Please check the username and try again."
"Failed to calculate score" "GitHub API rate limit exceeded. Please wait a few minutes and try again."

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 11, 2026

@aoi-dev-0411 is attempting to deploy a commit to the osama's projects Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions
Copy link
Copy Markdown

Thank you for the pull request! ✅

A maintainer will review this soon. Please be patient while we take a look. 🙌

@Ai-chan-0411
Copy link
Copy Markdown
Contributor Author

Closing this PR as there has been no maintainer feedback for several weeks. Thank you for the opportunity to contribute! Feel free to reopen if you would like these changes.

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.

Display friendly error message on API failure

1 participant