PlaybookPrompts

Audit error handling gaps in async or promise-based code

Coding & Development asyncerror-handlingreliability

Async code is where error handling silently fails most often — unhandled rejections, swallowed exceptions, and missing fallbacks cause production incidents. This prompt audits a code block specifically for these gaps.

Prompt
You are a reliability engineer auditing async code for error handling gaps. I have a block of asynchronous code that I want to harden before it ships.

Language: {{LANGUAGE}} (e.g. JavaScript/TypeScript with Promises, Python with asyncio, Kotlin coroutines)

Code to audit:
```
{{ASYNC_CODE_BLOCK}}
```

Context on failure tolerance: {{FAILURE_TOLERANCE}} (e.g. 'this runs in a background worker — partial failure is acceptable' or 'this is in the critical checkout path — any failure must surface to the user')

Follow these steps:

1. List every async call, Promise, or awaited expression in the code.
2. For each one, identify whether it has explicit error handling (try/catch, .catch(), Result type, etc.).
3. Flag any async call with no error handling at all. These are highest priority.
4. Flag any catch block that swallows errors silently (catches but does not log, rethrow, or return an error state).
5. Flag any place where a failed async call could leave shared state (variables, DB records, cache) in a partially-updated state.
6. For each flagged issue, suggest the minimum viable fix. Do not redesign the whole function — only patch the gaps.
7. If any fix changes observable behavior (e.g. now surfaces an error that was previously hidden), call that out explicitly.

Do not suggest converting the entire codebase to a Result/Either pattern unless the existing code already uses one.
Variables to fill in
  • {{LANGUAGE}}
  • {{ASYNC_CODE_BLOCK}}
  • {{FAILURE_TOLERANCE}}

How to use this prompt

  1. Copy the prompt above (Copy button on the top-right).
  2. Replace each {{VAR}} with your own value. Variables: {{LANGUAGE}}{{ASYNC_CODE_BLOCK}}{{FAILURE_TOLERANCE}}.
  3. Paste it into one of the recommended tools below.
  4. Iterate: tighten constraints in the prompt if the output is generic.

Why this prompt is structured this way

The prompt is split into explicit steps because LLMs do better when the path is named, not implied. Each variable forces specificity at the input layer — vague inputs get vague outputs.

Heads up: some of the links on this page are affiliate links — meaning we may earn a commission if you sign up after clicking, at no extra cost to you. We only recommend tools we'd put on our own stack. You can see our full affiliate disclosure here.

Pair this prompt with a tool

The PlaybookPrompts weekly

One short email per week. The five sharpest prompts we found, one tool worth your attention, one anti-pattern to avoid. Unsubscribe in one click.

Newsletter signup is not configured. Set PUBLIC_NEWSLETTER_USERNAME in the build env.