We can't find the internet
Attempting to reconnect
Something went wrong!
Attempting to reconnect
Error Handling with Exceptions, Retries and Warnings
PythonRead 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.
Your learning sequence
- 1 Read a Python Traceback Read
- 2 Design Exceptions Your Callers Can Catch Read
- 3 Not solved yet. Catch Errors by Category Practice · Easy
- 4 Not solved yet. Build a Payment Error Hierarchy Practice · Medium
- 5 Keep the Original Error with raise from Read
- 6 Not solved yet. Wrap a Low-Level Error with raise from Practice · Easy
- 7 Not solved yet. Translate Library Errors into Your Own Practice · Medium
- 8 Where to Catch an Exception Read
- 9 Not solved yet. Fix a Batch Runner That Catches Too Much Practice · Medium
- 10 Report Several Errors at Once with ExceptionGroup Read
- 11 Not solved yet. Collect Every Failure in a Batch Practice · Medium
- 12 Not solved yet. Split an Exception Group Without Losing Its Shape Practice · Hard
- 13 Retry Failed Calls with Backoff Read
- 14 Not solved yet. Retry a Fetch with Exponential Backoff Practice · Medium
- 15 Warn Callers with the warnings Module Read
- 16 Deprecate a Function Without Breaking Callers Read
- 17 Not solved yet. Report Calls to Deprecated Functions Practice · Medium
- 18 Mark Functions That Never Return Read
- 19 Type Hints for Code That Can Fail Read
- 20 Not solved yet. Return Errors as Values with a Result Type Practice · Hard
Check yourself
6 questions · not saved while you're signed outUse these questions to check your understanding and compare explanations. Your score does not affect track completion.
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')