Programming Concepts: What should be done when an exception is thrown?

Posted by Dooms101 on Stack Overflow See other posts from Stack Overflow or by Dooms101
Published on 2010-04-08T16:21:45Z Indexed on 2010/04/08 16:23 UTC
Read the original article Hit count: 274

This does not really apply to any language specifically, but if it matters I am using VB.NET in Visual Studio 2008.

I can't seem to find anything really that useful using Google about this topic, but I was wondering what is common practice when an exception is thrown and caught but since it has been thrown the application cannot continue operating.

For example I have exceptions that are thrown by my FileLoader class when a file cannot be found or when a file is deemed corrupt. The exception is only thrown within the class and is not handled really. If the error is detected, then the exception is thrown and whatever function is was thrown is basically quits.

So in the code trying to create that object or call one of its members I use a Try...Catch statement. However, I was wondering, what should even do when this exception is caught? My application needs these files to be intact, and if they are not, the application is almost useless. So far I just pop up a message box telling the user their is an error and to reinstall. What else can I do, or better, what's common practice in these situations?

© Stack Overflow or respective owner

Related posts about language-agnostic

Related posts about error-handling