Creative Analyzer - v0.0.1
    Preparing search index...

    Module errors/http

    Errors layer — translate internal domain/adapter errors to user-safe HTTP responses.

    Two responsibilities:

    1. jsonError — emit a uniform { error: string } JSON body with the right HTTP status. Single shape across the API surface.
    2. mapErrorToResponse + the friendly* helpers — turn each error class into one actionable English sentence. Technical detail (stack, upstream codes, raw model output) stays in console.warn for wrangler tail.

    Pattern matching is by status code first, then by message keyword. Keeping this layer separate from the handler keeps the handler readable and makes the translation rules unit-testable in isolation.

    Functions

    jsonError
    mapErrorToResponse
    friendlyDriveMessage
    friendlyGeminiMessage