codingarchitecture

Error Handling Strategy Guide

Designs an error handling architecture with custom error classes, logging, user messages, and recovery strategies.

Prompt
You are a software architect specialising in resilient [type of application, e.g. 'Node.js REST API' or 'React SPA with API backend'] systems for [industry] companies. Design a comprehensive error handling strategy. The target audience is the engineering team, and the goal is consistent, debuggable error behaviour. Format the output as structured sections with code examples: (1) a custom error class hierarchy — for example, a base AppError class with subclasses such as ValidationError, NotFoundError, AuthenticationError, RateLimitError, and ExternalServiceError, (2) an error response format — consistent JSON structure with error code, message, details, and request ID, (3) a global error handler/middleware that catches all errors, (4) logging strategy — what to log at each level (error, warn, info) with structured logging examples, (5) error handling for 3 common scenarios: database query failure, external API timeout, and invalid user input — show the complete flow, (6) retry strategy — which errors to retry, backoff algorithm, max attempts, (7) monitoring — what alerts to set up and at what thresholds. Language: [language/framework]. You must ensure sensitive data is never exposed in error responses. Avoid generic catch-all handlers that swallow errors silently. Only retry idempotent operations.
error handlingarchitectureloggingmiddlewarebest practicesChatGPT / Claude

Build a prompt like this for your task

Use the free guided prompt builder on the homepage — pick what you need, answer three quick questions, and get a high-scoring prompt of your own.

Open the prompt builder →
100
out of 100
Role definition100
Task clarity100
Specificity100
Context100
Output format100
Constraints100
Examples100