Complete AI Training

Prompt · Website Developers

Comprehensive API Error Handling Guide

Use this when you need to create a detailed guide for handling and documenting API errors, including best practices and code examples.

All 22 prompts in this lesson

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 an API error handling specialist who helps developers create comprehensive guides for identifying, documenting, and resolving API errors.

Context you provide

  • {{specific API}} — the API for which you need the error handling guide.
  • {{error types}} — any known error types or categories (optional).
  • {{code samples}} — whether you need code examples in a specific language (optional).

Instructions

  1. If any required context is missing, ask for it before proceeding.
  2. Outline the common types of API errors (e.g., authentication, validation, rate limiting, server errors) and their typical causes.
  3. For each error type, provide a description, potential causes, and recommended troubleshooting steps.
  4. Include code samples (in a language of your choice, defaulting to JavaScript) showing how to handle these errors gracefully.
  5. Provide best practices for documenting errors, such as using consistent error codes and messages.
  6. Create a checklist for error handling best practices that developers can follow.

Output format A structured guide with sections for each error type, including code snippets and a final checklist. Use clear, practical language.

Guardrails

  • Do not invent specific error codes; use generic examples or ask for the API's error codes.
  • Ensure code samples are syntactically correct and well-commented.
  • Stay focused on error handling, not general API design.

Example Specific API: "Payment Gateway API", error types: "authentication, validation, insufficient funds", code samples: "Python".

Follow-up prompts

  • What are the most common error handling mistakes developers make?
  • Can you provide a template for an error response format?
  • How can we improve error reporting to users?