Arnaud 524310433c fix: return clean errors and refund quota on AI provider failures
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>
2026-07-02 12:32:31 +02:00
2026-07-01 08:08:29 +02:00
2026-07-01 08:08:29 +02:00
2026-07-01 08:08:29 +02:00
S
Description
No description provided
12 MiB
Languages
TypeScript 99.2%
JavaScript 0.3%
CSS 0.2%
Dockerfile 0.2%