Intermediate Reading #stack-traces #logs #debugging

🔴 Reading: Error Messages & Logs

3 exercises — read real Python stack traces, application logs, and error messages. Identify what went wrong, on which line, and why.

Reading stack traces: top-down or bottom-up?
  • Read bottom to top: the error type and message are at the bottom
  • The line just above is where the error actually occurred
  • Read upward to trace the call chain
  • In logs: read chronologically — events tell a story
0 / 3 completed
1 / 3
🔴 Python Stack Trace
Traceback (most recent call last):
  File "app/services/order_service.py", line 87, in process_order
    total = calculate_total(items)
  File "app/utils/pricing.py", line 34, in calculate_total
    return sum(item['price'] * item['quantity'] for item in items)
  File "app/utils/pricing.py", line 34, in <listcomp>
    return sum(item['price'] * item['quantity'] for item in items)
KeyError: 'price'
Read the stack trace above. Which statement accurately describes what happened?