Exception Handling Best Practice
For each projects that I do not own, I see different kind of Exception Handling, almost one different way per project... I'll let you know what should be the way to do it, and why... Note that there is many ways of doing the right way.
First Rule: If you trap an exception, it's because you want to do something with it.
Do not catch and rethrow, if you rethrow, it's because you want to add additionnal information on the error. If not, do not try and catch.
Second Rule: Trap the exception "Exception" globally at one place, only one place.
On the web, catch it in the global.asax using the GetLastError in the Application_Error event.
Exception LastError = Server.GetLastError();
Third Rule: Throw exception of the right kind, with messages.
Inherit ApplicationException for custom error, ArgumentException and other, but use it. After that you can trap all the ArgumentException globally for all them.
That's almost my philosophy, if you have other rules or details on those, feel free to comment! Everything can be improve.
-f.