Skip to content
PromptPilot AI

Library / Coding & Technology / Refactoring

Node.js: centralise error handling

One error middleware, typed errors, no leaked stack traces.

Cursor / coding agentsClaude CodeChatGPTClaudenode
Who it's for
Developers using AI coding tools
Use case
Refactoring
Output
Agent task · Free
You'll need to fill in
framework
Prevents: Unhandled promise rejections and stack traces leaking to clients.
Introduce centralised error handling in this [framework] app.
- Define a small set of typed application errors (NotFound, Validation, Unauthorized, Conflict).
- Add one error-handling middleware/hook that maps them to HTTP responses and logs unexpected errors without leaking stack traces to clients.
- Ensure async handlers' rejections reach the handler.
- Update 2–3 existing routes as examples and add tests for each error type.

Copies your prompt and opens the official site in a new tab. You may need to paste it yourself (Ctrl/⌘ + V). Nothing is sent to the AI by us.

Replace [bracketed] parts with your own details before sending. Want it tailored? Build a custom website & app development prompt.

Before vs after

A typical one-line request compared with this prompt. We only show sample responses where we've written an illustration.

BeforeWhat people usually type

Prompt

refactoring

1 words · no role, context, format or constraints

AfterThis library prompt

Prompt

Introduce centralised error handling in this [framework] app.
- Define a small set of typed application errors (NotFound, Validation, Unauthorized, Conflict).
- Add one error-handling middleware/hook that maps them to HTTP responses and logs unexpected errors without leaking stack traces to clients.
- Ensure async handlers' rejections reach the handler.
- Update 2–3 existing routes as examples and add tests for each error type.

64 words · generated instantly from templates, no AI called

What we added

  • Your details: [brackets] for the facts only you know

Related prompts