Complete AI Training

Prompt

Map API Errors to User Messages

Use this when you want to map API status codes and network failures to clear, user-friendly messages in a mobile app.

How to use it

  1. Copy the prompt and paste it into ChatGPT, Claude, Gemini or any other AI.
  2. Replace every {{placeholder}} with your own details, or let the AI ask you for them.
  3. Use the follow-ups below to go deeper.
Prompt

Role: You are a mobile app developer who turns API status codes and network failures into clear, user-friendly messages that keep users oriented and reduce support tickets. Optimise for accurate recovery paths, not technical detail.

Context you provide:

  • {{platform_and_framework}}: e.g., SwiftUI, Jetpack Compose, React Native
  • {{api_spec_or_endpoints}}: endpoints plus status codes you handle
  • {{known_failure_modes}}: timeouts, offline, rate limits, validation errors
  • {{existing_error_handling}}: current pattern or code, if any
  • {{brand_tone}}: voice, formality, emoji policy
  • {{screen_or_journey}}: where the error appears

Instructions:

  1. Ask for any missing inputs, then confirm the platform and API surface.
  2. Build a mapping table: each code or failure condition, its plain-language cause, who is responsible (user, server, network), and whether retry is possible.
  3. Write one user-facing message per row. Keep it specific, calm, and actionable. No status codes or internal terms in the message.
  4. Assign a recovery action: retry, edit input, sign in again, contact support, or continue offline.
  5. Give a small code example for a central error mapper and fallback UI on the stated platform.
  6. Cover edge cases: offline, slow network, partial success, expired session, maintenance.

Output format: Markdown. One table: Condition or code | Cause in plain language | User message | Recovery action. Then a code block for the mapper. Then a short bullet list of edge cases. Under 800 words. Tone: practical and direct.

Guardrails:

  • Do not invent status codes, error codes, or API behaviour. Flag missing cases as assumptions.
  • Never expose stack traces, server names, or internal identifiers in user-facing copy.
  • If the flow involves payments, authentication, or personal data, tell the user to check platform review guidelines and their security or legal team.

Example: Platform: React Native; API: /login returns 401, 429, 500; failure modes: offline, timeout; brand tone: friendly and brief; journey: sign-in screen.