Skip to content
PromptLab by FEHMER TECH
ENDE
Coding

Error Handling Strategy

Implement robust error handling with custom exceptions and logging.

Prompt template

Design and implement a comprehensive error handling strategy for [PROJECT DESCRIPTION] in [PROGRAMMING LANGUAGE].

**Current Situation:**
- Architecture: [Monolith/Microservices/Serverless]
- Framework: [FRAMEWORK]
- Critical operations: [LIST OF CRITICAL OPERATIONS]

**Please implement:**
1. **Exception Hierarchy:** Custom exception classes with:
   - Base exception with error code and message
   - Specific exceptions per domain (ValidationError, NotFoundError, etc.)
   - HTTP status code mapping

2. **Error Handler:** Central error handling with:
   - Distinction between operational and programmatic errors
   - User-friendly error messages (without internal details)
   - Structured error logging

3. **Retry Logic:** For transient errors:
   - Exponential backoff with jitter
   - Circuit breaker pattern
   - Configurable retry limits

4. **Validation:** Input validation with meaningful error messages

5. **Monitoring:** Error tracking integration (Sentry/Datadog)

Show complete code examples for each aspect.

Replace placeholders in [square brackets]: [PROJECT DESCRIPTION][PROGRAMMING LANGUAGE][Monolith/Microservices/Serverless][FRAMEWORK][LIST OF CRITICAL OPERATIONS]

How to use this template

Copy the prompt, replace the placeholders in square brackets with your details and paste it into the AI assistant of your choice. The more precise your details, the better the result.

Tips for better results

  • Describe the architecture and critical failure cases
  • Specify whether errors should be formatted for end users or developers
  • Ask for circuit breaker implementations
  • Request error tracking integration (Sentry, Datadog)

Suitable open models

The selection names current open models as a starting point for your own tests. It is not a measurement for this template.

Keywords: #error-handling #exceptions #resilience #monitoring

Last updated: