Skip to content
← All Python tracks

Error Handling with Exceptions, Retries and Warnings

Python

Read a traceback, catch errors by category, and design exceptions your callers can act on. Keep the original error when you wrap it, report several failures at once, retry failed calls, and warn callers before you remove a function.

This track uses Python. You can make it your practice mode to browse related content across the site.

10 exercises

10 articles

Explore freely. Sign in to keep your progress.

Your learning sequence

  1. 1 Read a Python Traceback Read
  2. 2 Design Exceptions Your Callers Can Catch Read
  3. 3 Not solved yet. Catch Errors by Category Practice · Easy
  4. 4 Not solved yet. Build a Payment Error Hierarchy Practice · Medium
  5. 5 Keep the Original Error with raise from Read
  6. 6 Not solved yet. Wrap a Low-Level Error with raise from Practice · Easy
  7. 7 Not solved yet. Translate Library Errors into Your Own Practice · Medium
  8. 8 Where to Catch an Exception Read
  9. 9 Not solved yet. Fix a Batch Runner That Catches Too Much Practice · Medium
  10. 10 Report Several Errors at Once with ExceptionGroup Read
  11. 11 Not solved yet. Collect Every Failure in a Batch Practice · Medium
  12. 12 Not solved yet. Split an Exception Group Without Losing Its Shape Practice · Hard
  13. 13 Retry Failed Calls with Backoff Read
  14. 14 Not solved yet. Retry a Fetch with Exponential Backoff Practice · Medium
  15. 15 Warn Callers with the warnings Module Read
  16. 16 Deprecate a Function Without Breaking Callers Read
  17. 17 Not solved yet. Report Calls to Deprecated Functions Practice · Medium
  18. 18 Mark Functions That Never Return Read
  19. 19 Type Hints for Code That Can Fail Read
  20. 20 Not solved yet. Return Errors as Values with a Result Type Practice · Hard

Check yourself

6 questions · not saved while you're signed out

Use these questions to check your understanding and compare explanations. Your score does not affect track completion.

0 / 6 correct

Which handler prints a message for this ValueError?

Choose one answer to reveal the explanations. Answers are kept only while this page is open.

try:
    raise ValueError('v')
except Exception:
    print('broad')
except ValueError:
    print('specific')
Question 1 of 6