mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-01-30 06:12:03 +00:00
feat: improve rate limit error handling with user-friendly messages
- Add rate_limit error type to ErrorInfo classification - Implement isRateLimitError() and extractRetryAfter() utilities - Enhance ClaudeProvider error handling with actionable messages - Add comprehensive test coverage (8 new tests, 162 total passing) **Problem:** When hitting API rate limits, users saw cryptic 'exit code 1' errors with no explanation or guidance on how to resolve the issue. **Solution:** - Detect rate limit errors (429) and extract retry-after duration - Provide clear, user-friendly error messages with: * Explanation of what went wrong * How long to wait before retrying * Actionable tip to reduce concurrency in auto-mode - Preserve original error details for debugging **Changes:** - libs/types: Add 'rate_limit' type and retryAfter field to ErrorInfo - libs/utils: Add rate limit detection and extraction logic - apps/server: Enhance ClaudeProvider with better error messages - tests: Add 8 new test cases covering rate limit scenarios **Benefits:** ✅ Clear communication - users understand the problem ✅ Actionable guidance - users know how to fix it ✅ Better debugging - original errors preserved ✅ Type safety - proper TypeScript typing ✅ Comprehensive testing - all edge cases covered See CHANGELOG_RATE_LIMIT_HANDLING.md for detailed documentation.
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
|
||||
import { query, type Options } from '@anthropic-ai/claude-agent-sdk';
|
||||
import { BaseProvider } from './base-provider.js';
|
||||
import { classifyError, getUserFriendlyErrorMessage } from '@automaker/utils';
|
||||
import type {
|
||||
ExecuteOptions,
|
||||
ProviderMessage,
|
||||
@@ -107,9 +108,32 @@ export class ClaudeProvider extends BaseProvider {
|
||||
yield msg as ProviderMessage;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('[ClaudeProvider] ERROR: executeQuery() error during execution:', error);
|
||||
console.error('[ClaudeProvider] ERROR stack:', (error as Error).stack);
|
||||
throw error;
|
||||
// Enhance error with user-friendly message and classification
|
||||
const errorInfo = classifyError(error);
|
||||
const userMessage = getUserFriendlyErrorMessage(error);
|
||||
|
||||
console.error('[ClaudeProvider] executeQuery() error during execution:', {
|
||||
type: errorInfo.type,
|
||||
message: errorInfo.message,
|
||||
isRateLimit: errorInfo.isRateLimit,
|
||||
retryAfter: errorInfo.retryAfter,
|
||||
stack: (error as Error).stack,
|
||||
});
|
||||
|
||||
// Build enhanced error message with additional guidance for rate limits
|
||||
const message = errorInfo.isRateLimit
|
||||
? `${userMessage}\n\nTip: If you're running multiple features in auto-mode, consider reducing concurrency (maxConcurrency setting) to avoid hitting rate limits.`
|
||||
: userMessage;
|
||||
|
||||
const enhancedError = new Error(message);
|
||||
(enhancedError as any).originalError = error;
|
||||
(enhancedError as any).type = errorInfo.type;
|
||||
|
||||
if (errorInfo.isRateLimit) {
|
||||
(enhancedError as any).retryAfter = errorInfo.retryAfter;
|
||||
}
|
||||
|
||||
throw enhancedError;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user