C# Exception Handling Fundamentals (not only for beginners)

preview_player
Показать описание
Exception handling in #DotNet and #csharp is not necessarily difficult, but it could come with a lot of caveats if we are not aware how exceptions are handled by the runtime. In this video I try to go from the very basics of a try - catch block to some more advanced topics like best practices for custom exceptions and much more.

Contents
1. Intro: 00:00
2. Overview of the demo app: 00:50
3. Basic try-catch-finally: 04:09
4. Examining stack traces: 12:18
5. Where to put try-catch blocks? 18:55
6. How to re-throw exceptions the right way: 20:17
7. Custom exceptions best practices: 25:00
8. The importance of inner exceptions: 29:01
9. Catch block order: 31:57
10: Conclusions: 38:41
Рекомендации по теме
Комментарии
Автор

Thank you. I request you not to stop making videos. You are helping lot of folks like me :)

VinuP
Автор

Great video. Where I get stuck is WHEN to actually throw exceptions, not HOW. In what scenarios is it right to throw an exception? For example, you could have a method that does division, and have a DivideByZero exception, or you could just check to see if it's zero first to avoid the exception. I don't know which way is the 'right way'.

I'd love for you to make a video showing best practice for WHEN exceptions should be thrown.

Love the videos. You explain things very well.

ekcodes
Автор

Thanks for the video, it was really good! When you can, also talk a little about unit tests in APIs.

arturfornagieri
Автор

Great tutorial - what do you think about Middle-Ware exception handling and having specific error handling around special scenarios like DB Concurrency or Deadlock (retry policy's etc.)?
PS: You should think about giving talks at Conferences....you know your stuff!

CarrigansGuitarClub
Автор

Thanks! Do you still do live sessions with these?

zaharivaklinov
Автор

There is another way to use exceptions, a wrong way that I saw in the production code: You create a custom exception that triggers some service then you throw that exception when a certain condition is fulfilled. It si very confusing.

bogdanalexandruburca
welcome to shbcf.ru