This video covers exception handling in Python and it gives you a few more advanced tips of how to handle exceptions in production environments, including using different exceptions at each level of your application, using a context manager to automatically clean up resources such as an open database connection, and using decorators to have an easy mechanism for retrying operations if an exception occurs, or automatically logging exceptions to a file.
After watching this video, make sure to watch my follow-up video that clarifies a few things from this video and also talks about another alternative for error handling: • Monadic Error Handling... .
💡Here's my FREE 7-step guide to help you consistently design great software: arjancodes.com/designguide.
Relevant books:
- Design Patterns: Elements of Reusable Object-Oriented Software by Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides: amzn.to/3jllgyH
- Applying UML and Patterns: An Introduction to Object-Oriented Analysis and Design and Iterative Development, by Craig Larman: amzn.to/364wgLb
- Principles of Package Design: Creating Reusable Software Components by Matthias Noback: amzn.to/2NETK3l
- Clean Code: A Handbook of Agile Software Craftsmanship by Robert Martin: amzn.to/3qVZgNs
- The original Design Principles and Design Patterns article by Robert Martin: fi.ort.edu.uy/innovaportal/fi... Courses:
The Software Designer Mindset: www.arjancodes.com/mindset
The Software Designer Mindset Team Packages: www.arjancodes.com/sas
The Software Architect Mindset: Pre-register now! www.arjancodes.com/architect
Next Level Python: Become a Python Expert: www.arjancodes.com/next-level...
The 30-Day Design Challenge: www.arjancodes.com/30ddc
🛒 GEAR & RECOMMENDED BOOKS: kit.co/arjancodes.
All parts in this series:
Part 1: Cohesion and coupling - • Cohesion and Coupling:...
Part 2: Dependency inversion - • Dependency Inversion: ...
Part 3: The strategy pattern - • The Strategy Pattern: ...
Part 4: The observer pattern - • Observer Pattern Tutor...
Part 5: Unit testing and code coverage - • 100% CODE COVERAGE - T...
Part 6: Template method and bridge - • Two UNDERRATED Design ...
Part 7: Exception handling - • Exception Handling Tip...
Part 7b: Monadic error handling - • Monadic Error Handling...
Part 8: Software architecture - • Why You Should Think A...
Part 9: SOLID principles - • Uncle Bob’s SOLID Prin...
Part 10: Object creation patterns - • QUESTIONABLE Object Cr...
You can find the code I worked on in this episode in my GitHub repository: github.com/arjancodes/betterp...
🔖 Chapters:
0:00 Intro
1:43 Example explanation
4:29 Running the example
5:59 Exception types and handling exceptions on different levels
12:43 Adding a context manager
16:12 Retry decorator
17:46 Automatic logging of exceptions
18:37 Disadvantages of handling errors by exceptions
19:47 Alternative ways of handling errors
21:20 Outro
👍 If you enjoyed this content, give this video a like. If you want to watch more of my upcoming videos, consider subscribing to my channel!
🏆 Join my Discord server: discord.arjan.codes
👥Twitter: / arjancodes
👥LinkedIn: / arjancodes
👥Facebook: / arjancodes
#arjancodes #softwaredesign #exceptionhandling
DISCLAIMER - The links in this description might be affiliate links. If you purchase a product or service through one of those links, I may receive a small commission. There is no additional charge to you. Thanks for supporting my channel so I can continue to provide you with free content each week!
Негізгі бет Exception Handling Tips in Python ⚠ Write Better Python Code Part 7
Пікірлер: 197