Skip to content
Sharp

Exceptions · interview question

A bug appears around error translation. What is the strongest first debugging move?

Multiple choiceHardchapter-5-curatedpremiumexceptionserror-translation
python
try:
    response = {"subtotal": "bad-number"}
    subtotal = float(response["subtotal"])
except ValueError as error:
    raise RuntimeError("partner payload used invalid subtotal") from error
Choose one answer
Answer and explanation

Correct answer

A. Trace one concrete example, inspect the state transitions, and compare them to the intended rule before rewriting anything.

Why

That approach is reliable because it creates evidence. Translating too early disconnects the caller from the technical clue, while translating too late leaks infrastructure details upward.

Test yourself on Exceptions

A free test with instant, explained results. No account needed.

Start free test
All Exceptions questions →