Exception Handling
-
Hi all, i have one doubt regarding exception handling statements sequence. we have various exceptions like.. System.ApplicationException System.ArgumentException System.ArgumentNullException System.ArithmeticException System.IO.FileNotFoundException System.IO.IOException ..................... .................... if we want to catch IO errors and some general errors in the same code ....then is there any sequence that we have to follow. i mean first catch block should handle only geneal exceptions, next catch block for IO errors... or we can use any order?? thanks, Rahi
If you look at what you do not have in life, you don't have anything, If you look at what you have in life, you have everything... "
-
Hi all, i have one doubt regarding exception handling statements sequence. we have various exceptions like.. System.ApplicationException System.ArgumentException System.ArgumentNullException System.ArithmeticException System.IO.FileNotFoundException System.IO.IOException ..................... .................... if we want to catch IO errors and some general errors in the same code ....then is there any sequence that we have to follow. i mean first catch block should handle only geneal exceptions, next catch block for IO errors... or we can use any order?? thanks, Rahi
If you look at what you do not have in life, you don't have anything, If you look at what you have in life, you have everything... "
Rahithi wrote:
if we want to catch IO errors and some general errors in the same code ....then is there any sequence that we have to follow
You should start with the most specific exceptions first and move to the more general. You can work out which are specific and which are general by looking at the base class of each exception. The most general (and therefore last) exception is
Exception
.
Upcoming events: * Edinburgh: Web Security Conference Day for Windows Developers (12th April) * Glasgow: Introduction to AJAX (2nd May), SQL Server, Mock Objects My website