Read the Error First
Kitty's balances page crashes for one flat. The error fills the screen, and the reflex is to copy all of it into the assistant without reading a word. Sometimes that works. But thirty seconds of reading first makes your prompt sharper, teaches you something, and, most importantly, lets you tell whether the assistant's fix addresses the real cause.
The rule
Read the error yourself first: what failed, where, and your guess why.
In Python, a crash prints a traceback:
Traceback (most recent call last):
File "kitty/app.py", line 42, in balances_page
rows = compute_balances(db, flat_id)
File "kitty/balances.py", line 17, in compute_balances
share = total // len(members)
~~~~~~^^~~~~~~~~~~~~~
ZeroDivisionError: division by zero(Recent Python versions underline the failing part of a line with ~ and ^, as here; older versions leave the underline out, and message wording can differ slightly between versions.) It reads like this:
- The last line says what failed: the type of error and a message. Here, something was divided by zero.
- The lines above show the chain of calls, with the most recent call last. Each entry names a file, a line number and a function, then shows that line of code.
- The lowest entry in your own files is usually where to look. If a traceback runs on into a library, the mistake is still more likely in how your code called it.
Then comes the step that makes it yours: a guess. At line 17, len(members) must be 0. When would a flat have no members? Flat 7's flatmates all moved out last month.
The shortcut
Say three things before prompting: what, where, why. What is the last line. Where is the lowest entry in your own code. Why is your one-sentence guess. Put all three in the prompt, along with the behaviour you actually want.
What
ZeroDivisionError: a division by zero.
The trap is the fix that makes the error message disappear rather than the cause. With your own "why" in hand, you can tell the difference.
Drills
Answer fast — trust the rule.
In a Python traceback, where do you find the type of error and its message?
A traceback runs through your files and then into a library. Where do you usually look first?
Why form your own guess before prompting?
The assistant "fixes" the crash with except Exception around the block, setting the share to 0. What is the problem?
Remember
- Rule: read the error yourself first: what failed, where, and your guess why.
- Shortcut: last line for what, lowest entry in your own code for where, one sentence for why.
- Trap: accepting a fix that hides the error message instead of fixing its cause.
