524310433c4ff2c80fdfacb3d4a16bdd3686d1e0
AI routes had no consistent error handling — a provider failure (e.g. OpenRouter returning a degraded-model error) crashed the route as an uncaught 500 and, worse, still charged the user's monthly aiCall quota for a request that never succeeded. Adds withAiQuota()/aiErrorResponse() (lib/ai/ai-error.ts) and applies them across all 12 AI generation routes: charges the quota, runs the AI call, refunds the credit and returns a clean user-facing message if it throws. Frontend needs no changes — existing dialogs already toast whatever `error` string comes back. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Description
No description provided
Languages
TypeScript
99.2%
JavaScript
0.3%
CSS
0.2%
Dockerfile
0.2%