Skip to content

Implement structured API error handling and enhance timeout management#8

Merged
voidcommit-afk merged 3 commits intomainfrom
dev
Mar 22, 2026
Merged

Implement structured API error handling and enhance timeout management#8
voidcommit-afk merged 3 commits intomainfrom
dev

Conversation

@voidcommit-afk
Copy link
Owner

This pull request introduces improved handling of API error responses across both backend and frontend, with a focus on better error messaging, quota/rate limit awareness, and user experience. The backend now passes a pro flag to request control logic, ensuring that Pro users bypass quota checks. On the frontend, a new unified error parsing utility provides clearer feedback to users, especially around quota and rate limiting, and controls when retries are allowed.

The most important changes are:

Backend: Pro User Handling and Quota Checks

  • Added an is_pro flag to the enforce_request_controls function and its callers, ensuring that Pro users are exempt from daily quota checks. This affects both chat message and topic query endpoints. [1] [2] [3] [4] [5] [6]

  • Improved streaming response handling to ensure that partial responses and errors are properly cached and labeled, and that users are informed when a connection is interrupted, with messaging tailored to the selected mode (e.g., "technical" or "socratic"). [1] [2]

Frontend: Unified API Error Handling and Messaging

  • Introduced a new buildApiError utility in src/lib/httpErrors.ts to standardize error parsing and messaging for API responses, including quota and rate limit errors. [1] [2] [3] [4]

  • Updated all API request functions (fetchAPI, queryTopic, queryTopicStream, and chat service) to use the new error utility, providing more detailed and user-friendly error messages and controlling retry logic based on error detail (e.g., not retrying on quota exceeded). [1] [2] [3] [4] [5] [6] [7]

API Improvements

  • Enhanced timeout and abort handling in API requests to provide more accurate error messages when requests time out or are aborted, and to prevent retries when not appropriate. [1] [2] [3] [4] [5]

These changes result in a more robust user experience, clearer error feedback, and improved handling of Pro user privileges and quota enforcement.

@voidcommit-afk voidcommit-afk merged commit 04180dc into main Mar 22, 2026
5 checks passed
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.

1 participant