Skip to content

How can my app display generation errors without leaking raw server details?

Map known error codes to concise user messages and show a safe reference for unexpected failures. Do not inject raw upstream text into HTML or expose stack traces, credentials or internal URLs. Your application owns this presentation layer; AISwapLab's error envelope is input to that mapping.

DESIGN A CLEAR API PRODUCT EXPERIENCEAISwapLab team · Editorial methodPublished 2 min read
Open API documentationExplore 67 Image SkillsPrivate keys · Explicit credit approval
Article workflow: Define public error variants; Render as text; Exercise hostile messages.
Workflow diagram: Define public error variants → Render as text → Exercise hostile messages. Read the article for evidence and limits.

An error message is untrusted content

Even a server-provided message can include unexpected punctuation, reflected input or operational detail. Classifying an error for retry decisions and deciding what a user should see are separate tasks. A useful message identifies the blocked action and next safe step.

What to do next

  1. 01

    Define public error variants

    Create a small message catalog for validation, unavailable models, spending limits and stale results, using your own localized wording. Keep a separate fallback that admits the operation could not be confirmed without inventing a cause.

  2. 02

    Render as text

    Use ordinary text rendering for error strings and avoid raw HTML insertion. Give developer diagnostics a restricted storage path, redacting secrets and user media references before they enter logs or support tools.

  3. 03

    Exercise hostile messages

    Test messages containing tags, long text, control characters and a fake internal URL. Confirm that users see safe text, the layout remains usable, and a support reference links to the correct internal incident evidence.

A concrete example

Illustrative example: an unexpected response contains a long gateway traceback. The customer sees We could not check this result; reference R42. Authorized operators can inspect the redacted diagnostic behind R42 without displaying it in the public page.

Before you call it ready

  • Markup remains inert.
  • No private URL reaches the banner.
  • Every fallback has a practical next action.

When to stop or choose another method

Stop forwarding raw exception messages to customers when their contents and disclosure scope have not been reviewed.

Sources

One task. A recoverable workflow.

Check the contract, approve the quote and retain the job.

Open API documentation