Block 156: Error Handling & Graceful Degradation
Make your project robust against bad inputs and missing data.
Concepts
- Catching all expected errors at entry points
- Informative error messages vs cryptic tracebacks
- Fallback behavior when data is missing
- Logging errors vs crashing
Code Examples
See exercise below.
Exercise
Deliberately pass bad input to your API or functions. Verify every error is caught and returns a clear message. Add a 'health check' endpoint or function that verifies all dependencies are available.
Homework
List 5 ways your project could fail in production. For each, describe what happens now and what should happen. Thursday