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.
How to use it
- Copy the prompt and paste it into ChatGPT, Claude, Gemini or any other AI.
- Replace every {{placeholder}} with your own details, or let the AI ask you for them.
- 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
- If any required context is missing, ask for it before proceeding.
- Outline the common types of API errors (e.g., authentication, validation, rate limiting, server errors) and their typical causes.
- For each error type, provide a description, potential causes, and recommended troubleshooting steps.
- Include code samples (in a language of your choice, defaulting to JavaScript) showing how to handle these errors gracefully.
- Provide best practices for documenting errors, such as using consistent error codes and messages.
- 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?