Exception Handling Approach ?

G

Guest

I am developing a new project in which we should have a good Exception
Handling. Ive seen there is a Exception Handling App Block in Enterprise
Library, also I could use the Try-Catch structure itself...
What would be the best Approach ?
 
G

Greg Young

You will be using both. Some exceptions you expect (and handle) other ones
you don't in which case they should fall to your unhandled exception
handler. Just be explicit as possible in your try catches ..

ex:

BAD

try {
File.Open ( ... )
}
catch(Exception Ex) {
MessageBox.Show("Could not open file " + Filename);
}

GOOD
try {
File.Open ( ... )
}
catch(FileNotFoundException Ex) {
MessageBox.Show("File not found " + Filename);
}

Cheers,

Greg Young
MVP - C#
http://codebetter.com/blogs/gregyoung
 
G

Guest

Greg,
the example u posted does not use EntLIbrary, right?
I need to understand in which cases I would use EntLibrary
ExceptionHandling...
 
G

Greg Young

That example for another exception would fall out to the default exception
handler ...

The entlib is often used with a default exception handler ..

Aside from that I would recommend a read through one of the many articles
available such as http://www.devx.com/dotnet/Article/31463

Cheers,

Greg
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top