The prompt
Review this code and suggest error handling improvements:
[INSERT YOUR CODE HERE] What it is
Code Error Handling Reviewer is a prompt focused on one of the most commonly neglected aspects of code quality: proper error handling. It asks the AI to examine code and identify where errors could occur but are not being caught, where error messages could be more informative, and where recovery strategies could be improved. This is distinct from a general code review or an error explanation prompt. It does not explain what an error means -- it proactively finds places where errors could happen and suggests how to handle them. Missing null checks, unhandled promise rejections, empty catch blocks, and silent failures are all targets. The prompt is especially useful before deploying code to production. Code that works in development often fails in production due to unexpected inputs, network issues, or resource limits. Having the AI audit your error handling helps you anticipate and prepare for these failure modes before they become incidents.
Who it's for
- Developers
- Backend engineers building reliable and production-ready systems
Requirements
Requirements
- Any AI chatbot (ChatGPT, Claude, Gemini)
برومبت يطلب من الذكاء الاصطناعي مراجعة الكود واقتراح تحسينات لمعالجة الأخطاء مثل إضافة كتل try-catch والتعامل مع الحالات الاستثنائية.
Examples
From the source
PromptReview this code and suggest error handling improvements:
[INSERT YOUR CODE HERE]Expected output: From PickleBoxer's dev-chatgpt-prompts collection on GitHub.
Pros & cons
Pros
- Pro:Catches common error handling gaps that are easy to miss during development
- Pro:Helps build more resilient applications by systematically addressing failure modes
Cons
- Con:The AI may suggest overly defensive error handling that adds boilerplate without real benefit
- Con:Error handling strategies depend heavily on your application's architecture, which the AI may not fully understand from a code snippet
Tips
- Include context about where the code runs (API endpoint, background job, CLI tool) so the AI can suggest appropriate error recovery strategies
- Ask for both the error handling code and user-facing error messages
- Request logging recommendations alongside error handling for better observability