CodingSaves ~1 hour

Implement robust error handling patterns

Transform brittle, silent error handling into a robust, observable error strategy.

The prompt

You are a senior engineer improving error handling in a [LANGUAGE] application. Review the following code and implement a robust error handling strategy. Apply: custom error classes with meaningful names and properties, error boundary patterns (try/catch at appropriate levels, not everywhere), error context enrichment (adding request ID, user ID, timestamp), separation of operational errors vs programming errors, user-facing vs developer-facing error messages, proper async error propagation, and centralized error logging. Show the before and after code with an explanation of each pattern introduced.

Framework: [FRAMEWORK e.g. Express / FastAPI / Next.js]
Current code: [PASTE CODE WITH POOR ERROR HANDLING]
Logging tool: [LOGGER e.g. Winston / Pino / Sentry]

Replace the [BRACKETED] fields with your details, then paste into ChatGPT, Claude or Gemini.

Want AI to fill this in for you?

Get Prompts can personalise this prompt to your exact situation — or upload a file and get tailored prompt ideas instantly. 3 free edits, no sign-up.

Try it free →

More coding prompts