Friday, May 21, 2004

Handling Exceptions

Just read an article by Daniel Appleman in .Net Developer's Journal on Handling exceptions. For new programmers or those new to .Net Try... Catch may seem like a simple way to avoid UnHandled exceptions, and pretty them up. That's all I used them for. But I had heard of more you could do with them.

Dan's article was extremely well written. Simple and to the point it helped me to understand this great facet of .Net better. I knew that you could handle different types of exceptions by having different Catch statements, almost like a Select statement. I also knew, however, that this should not be used as logic flow.

Example: If you have code that should accept a numeric, and somebody enters text, you shouldn't use exception handling for this, you should do something like IsNumeric.

What Dan really helped me to understand is what the difference between a SystemException and ApplicationException is. Also, why you would want to roll your own exceptions for let's say a namespace or class.

This .Net Dev Journal has some nice articles on SQL Server Reporting that I'll have to spend more time with. For now, it's back to projects.

No comments: