-
Notifications
You must be signed in to change notification settings - Fork 17
refactor: enhance error handling and API response management #483
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
Conversation
Jipperism
commented
Jan 10, 2026
- Refactored multiple API routes to utilize the new error handling utilities, ensuring consistent error responses and improved maintainability.
- Improved error handling in the Claim component to log errors more effectively and provide clearer feedback on proof generation failures.
- Updated axios fetcher to throw detailed errors based on API response codes.
- Introduced a new error handling utility in the API layer to standardize error responses across various endpoints, including bad requests and internal errors.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Closes #338 |
6812b51 to
5930ed3
Compare
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 pull request refactors error handling across multiple API routes to standardize error responses and improve maintainability. It introduces a new centralized error handling utility layer and updates axios fetcher to throw structured errors based on API response codes.
Changes:
- Introduced new error handling utilities (
lib/api/errors.tsandlib/api/types/api-error.ts) that standardize error responses with consistent structure (error message, error code, optional details) - Updated 15+ API endpoints to use the new error handling utilities, replacing inconsistent error responses with standardized ones
- Enhanced client-side error handling in axios fetcher and frontend components to parse and propagate structured error messages
Reviewed changes
Copilot reviewed 26 out of 26 changed files in this pull request and generated 15 comments.
Show a summary per file
| File | Description |
|---|---|
| lib/api/errors.ts | New centralized error handling utilities with functions for common HTTP error responses (400, 404, 405, 500, 502) |
| lib/api/types/api-error.ts | Type definitions for standardized API error structure with error codes |
| lib/axios.ts | Enhanced axios fetcher to extract and throw structured errors from API responses |
| utils/ipfs.ts | Added error handling for IPFS upload failures with structured error messages |
| components/Claim/index.tsx | Improved error handling for proof generation with proper error logging |
| pages/api/usage.tsx | Refactored to use new error utilities, removed nested try-catch block |
| pages/api/upload-ipfs.tsx | Updated to use new error handling utilities |
| pages/api/totalTokenSupply.tsx | Refactored with method validation and consistent error handling |
| pages/api/treasury/votes/[address]/registered.tsx | Updated to use new error utilities for validation and internal errors |
| pages/api/treasury/votes/[address]/index.tsx | Updated to use new error utilities for validation and internal errors |
| pages/api/treasury/proposal/[proposalId]/votes/[address].tsx | Updated to use new error utilities for validation and internal errors |
| pages/api/treasury/proposal/[proposalId]/state.tsx | Updated to use new error utilities for validation and internal errors |
| pages/api/score/index.tsx | Updated to use new error utilities |
| pages/api/score/[address].tsx | Updated to use new error utilities with specific external API error handling |
| pages/api/regions/index.ts | Updated to use new error utilities |
| pages/api/pipelines/index.tsx | Updated to use new error utilities |
| pages/api/pending-stake/[address].tsx | Updated to use new error utilities |
| pages/api/l1-delegator/[address].tsx | Updated to use new error utilities |
| pages/api/generateProof.tsx | Added input validation and consistent error handling |
| pages/api/ens-data/index.tsx | Updated to use new error utilities |
| pages/api/ens-data/image/[name].tsx | Updated to use new error utilities including notFound handling |
| pages/api/ens-data/[address].tsx | Updated to use new error utilities |
| pages/api/current-round.tsx | Updated to use new error utilities |
| pages/api/contracts.tsx | Updated to use new error utilities |
| pages/api/changefeed.tsx | Refactored with method validation and consistent error handling |
| pages/api/account-balance/[address].tsx | Updated to use new error utilities |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
ECWireless
left a comment
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.
Looks great! Though, copilot caught some super small stuff that I agree with
- Refactored multiple API routes to utilize the new error handling utilities, ensuring consistent error responses and improved maintainability. - Improved error handling in the Claim component to log errors more effectively and provide clearer feedback on proof generation failures. - Updated axios fetcher to throw detailed errors based on API response codes. - Introduced a new error handling utility in the API layer to standardize error responses across various endpoints, including bad requests and internal errors.
- Updated error handling in multiple API routes to throw detailed errors instead of returning bad requests, enhancing clarity in error reporting. - Enhanced the axios fetcher to provide more informative error messages based on API response codes. - Standardized error responses across various endpoints for better maintainability and consistency.
648a973 to
f002b7d
Compare
|
@ECWireless all PR feedback implemented. |