feat: display friendly error messages on API failure (closes #34)#53
feat: display friendly error messages on API failure (closes #34)#53Ai-chan-0411 wants to merge 2 commits intoO2sa:mainfrom
Conversation
|
@Ai-chan-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. |
|
Thank you for the pull request! ✅ A maintainer will review this soon. Please be patient while we take a look. 🙌 |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
O2sa
left a comment
There was a problem hiding this comment.
The error shown twice one in the compare-form and another in the result-dashboard.
And the error that's return from the API when the the username is invalid is:
{"success":false,"error":"Something went wrong. Please try again later."}
- Stop passing error prop to CompareForm component - Keep single error display in Alert component at page level - Improves UX by showing error in only one location - Addresses review feedback from O2sa (O2sa#53)
|
Hi @O2sa! Thank you for catching that - you're absolutely right about the duplicate error display. I've fixed the issue by removing the Key changes:
The fix is ready in commit Ai-chan-0411@7c3d01a Let me know if you'd like any adjustments! |
- Distinguish between user-not-found (404), rate-limit (429), network errors (503), and generic failures (500) in API route - Return appropriate HTTP status codes for each error type - Replace plain error div with Alert component using AlertCircle icon - Pass error prop to CompareForm for inline error display - Provide actionable guidance in each error message Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…shboard - Remove duplicate error Alert block from page.tsx (was shown twice) - Error is now displayed only via CompareForm's error prop - Improve invalid username detection in API route to handle GraphqlResponseError format from @octokit/graphql (catches 'Could not resolve to a User' messages) Signed-off-by: Ai-chan-0411 (藍) <aoikabu12@gmail.com>
b5a27b4 to
93ec162
Compare
Ai-chan-0411
left a comment
There was a problem hiding this comment.
Thanks for the review @O2sa! Here's what I fixed:
-
Duplicate error display: Removed the second
Alertblock that was rendering inpage.tsxafterCompareForm. The error is now shown only once, insideCompareFormvia itserrorprop. -
Invalid username showing generic error: Improved the error detection in
app/api/compare/route.ts. The@octokit/graphqlclient throws aGraphqlResponseErrorwith message"Could not resolve to a User with the login of '...'"rather than a simple"User not found". The route now checks for that pattern (and theerrors[].type === 'NOT_FOUND'field) so invalid usernames return the friendly 404 message instead of the generic 500.
|
The error still duplicated and even when the username is invalid it is shown the wrong error! |
Summary
divwith a styledAlertcomponent usingAlertCircleicon and descriptive titleCompareFormfor inline error display near the input fieldsCloses #34
Test plan
Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com