Back to guide/Developer Tools

Error Handling Hardening

Both editors can scan and fix files systematically. The specific audit checklist prevents vague 'improve error handling' outputs. Cursor shows inline diffs for each fix. Windsurf's Cascade can apply all fixes in sequence.

cursor-vs-windsurffile_or_module_pathcurrent_error_handling
Edit View
Prompt
Audit and improve error handling in {{file_or_module_path}}.

Current state: {{current_error_handling}}

Audit checklist:
1. **Unhandled promises**: Find any async operations missing try/catch or .catch()
2. **Silent failures**: Find catch blocks that swallow errors without logging or rethrowing
3. **Generic catches**: Replace catch(e) with specific error type handling where appropriate
4. **User-facing errors**: Ensure errors shown to users are helpful, not stack traces
5. **API boundaries**: Verify all API calls handle network errors, timeouts, and unexpected response shapes
6. **Validation gaps**: Find inputs that aren't validated before use

For each issue, provide:
- Location (file:line or function name)
- Current code
- Fixed code
- Why this matters (what could go wrong in production)

Then add:
- A centralized error handler if the project doesn't have one
- Retry logic for transient failures (network, rate limits) with exponential backoff
- Error boundary components for React UI sections that could crash

Variables to customize

{{file_or_module_path}}{{current_error_handling}}

Why this prompt works

Both editors can scan and fix files systematically. The specific audit checklist prevents vague 'improve error handling' outputs. Cursor shows inline diffs for each fix. Windsurf's Cascade can apply all fixes in sequence.

Save this prompt to your library

Organize, version, and access your best prompts across ChatGPT, Claude, and Cursor.