Finding and fixing program bugs
Take the error message and code, explain the root cause, and provide a step-by-step solution.
Prompt text
I am getting this error in the [Language or framework] application:
```
[Error message]
```
Related code:
```
[Code]
```
What I wanted to do: [Goal]
Kindly:
1. Explain in simple terms what the root cause of the error is.
2. Provide the corrected code.
3. Explain how to prevent this type of error in the future.
If you need more information to make a definitive diagnosis, ask instead of guessing.
Parts to replace
- [Language or framework]: e.g., Python 3.12 or React
- [Error message]: Full error text, including Traceback
- [Code]: The part of the code where the error occurs
- [Goal]: Short description
Why does this prompt work well?
Providing full error text + code + purpose are three inputs that any experienced programmer needs for debugging. The last sentence prevents speculative answers.
Pro tips
Write the language version and libraries; many errors are related to version differences.
Execution result on models
This prompt has not been executed in the lab yet.