Entries:
Comments:
Posts:

Loading User Information from Channel 9

Something went wrong getting user information from Channel 9

Latest Achievement:

Loading User Information from MSDN

Something went wrong getting user information from MSDN

Visual Studio Achievements

Latest Achievement:

Loading Visual Studio Achievements

Something went wrong getting the Visual Studio Achievements

Gracefully Handling Exceptions - 20

Download

Right click “Save as…”

Exceptions occur when an application experiences some unexpected problem at run time. This lesson discusses how to use the try catch finally block to anticipate potential problems and attempt to shield the end user from those problems as much as possible. We discuss best practices when checking for exceptions and discuss the mindset of the conscientious software developer who seeks to provide the best possible experience for his users.

Download the source code for Gracefully Handling Exceptions

 

Tags:

Follow the Discussion

  • I liked this video because it offered technique as well as theory and motive. Instead of just showing me how to handle exceptions so that I'm pleased with my software, it went on to explain why that should be a priority in my coding practices: I'm the advocate for my customer. Carrying that to conclusion:  if my customer is unhappy, I've both angered somebody and lost a customer. Both could be avoided by being conscientious in my coding.

  • @a14437: Awesome, thanks for that feedback.  I try to be empathetic in my explanations ... sometimes I hit and sometimes I miss.  Glad I "hit" on this one.  Big Smile

  • PaulPaul

    It would be nice if you proceed with our casts and cover every basic aspect of C#.
    Covering casting, generics, delegates, events etc.
    Just like an ordinary programming book.
    That would be really great. I wish you would find a time and effort for it :)
    Very nice casts though. Thanks a lot!

  • @Paul:  My friend, sounds like you're already way beyond this course.  Smiley  It was intended for absolute beginners.  The innards of delegates and events, and even generics to an extent is not a beginner topic.  I do have videos demonstrating those topics on my own website, however it was out of scope for this one.  Thank you and best wishes!

  • PaulPaul

    Thanks for the response :)
    Im just reading "Pro C# 2010" by Troelsen and it seems he is covering it in this way. I've just passed Exceptions topic in the book and trying to fix it in my mind by watching your casts :)
    Found even that you explained it much better than he does. I had been a little confused by his examples. :)
    Can you share your personal website here on send the link to my email?
    (iraunchy@gmail.com)
    I would really appreciate that. Thanks a lot!

  • AndrewAndrew

    Thanks a million for this. Found what i had been looking for. Would like to go beyond this... on to ultimate expertise in practice! Advize...

  • SebastianSebastian

    Thanks for this tutorial, it was pretty clear.
    However, I have a question: Since you included the finally part, where, as you said, we release connections to files, shouldn't you move the myReader.Close() in that finally block?

  • @Paul: http://www.learnvisualstudio.net

     

    @Andrew: On my own website I've got an extended version (22 hours) of this series complete with exercises & video solutions to challenge you.  It is so popular that moving forward, I'm structuring all new content around challenges / exercises / missions /etc.  Besides "instructor created challenges", the best way to get all of this solid in your mind?  Write code!  Smiley  Dream up a project and create it!  It will force you to think on your own feet, and struggle -- hopefully a positive / good kind of struggle (as opposed to the kind where you're just spinning your wheels and getting no where).


    @Sebastian: Yes, probably should have ... I don't have the code handy here right in front of me, but that would be a good place for it.  I *may* have been thinking it's possible for .NET to croak on closing the file, in which case, putting it in the finally would throw a second exception, this time, not caught.  But generally, yes, you are correct.  Smiley 

Remove this comment

Remove this thread

close

Comments Closed

Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums,
or Contact Us and let us know.