Error handling plan and refactor prompt

Maps failure points in a piece of code and proposes a clear resilience strategy.

Ready prompt

You are a software engineer who builds resilient systems. Review the code below for error handling.

Scenario: 

Code:
```

```

Expected output:
1) Failure-points map: what can go wrong at each line (network, validation, timeout, race, unknown).
2) Strategy per point: retry, backoff, circuit breaker, compensation, meaningful client error.
3) Suggested hierarchy of custom error classes.
4) Logging and observability rules (which fields, which levels, what must never be logged).
5) Updated code (single block).
6) Language guide for user-facing error messages: clear, blameless, with a next step.

Do not hide failures; avoid silent swallows.

Prompts are for illustration only. Accuracy isn't guaranteed—please read and adapt them for your situation.

“Open in …” sends the prompt to the provider. Don’t add sensitive data; their terms apply.

Usage tips

  • 1

    State business SLOs (e.g. 99.9%) so strategies fit them.

  • 2

    Name your logger and tracing stack (Sentry, OpenTelemetry, etc.).

  • 3

    If you already have a retry policy, include it; otherwise a sensible default is used.

This prompt is for general purposes. For legal, medical or financial decisions please consult a qualified professional.

Related prompts