error handling — when ai's code crashes mid-flight6 / 9
raising errors — making your code fail loudly on purpose
Claude shipped this and a teammate spent two days debugging a "missing
data" bug that turned out to be validate_order silently returning
None for any bad input. The except: pass swallows every exception
including bugs.
Replace the try/except block with a single raise ValueError(...)
that fails loudly when qty is not positive. Keep the message
"qty must be positive". The expected output (a traceback) just needs
to print qty must be positive somewhere — for this drill, change the
print at the bottom to wrap the call in a try/except ValueError as e: print(e) so the test can grade it.
The break is on lines 2, 3, 4, 5, 6 — but read the whole snippet first.
⌘↵ runs the editor.
Booting Python…
Output
[promptdojo:~]$ _