ExceptionHandling
Can we use multiple catch block for single try block in asp.net ? Please briefly Explain ...
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Saber ShaikhPosted Feb 4, 2015, 7:06 AM
Pranay RanaPosted Feb 4, 2015, 6:58 AM
you can have multiple catch block , but you should have least exception block at last so you dont miss any unhandle excpetion
try
{
}
catch(FileNoFoundExcpetion ex)
{
}
catch(UnAuthorizeExcpetion ex)
{
}
catch(Exception ex) //general exception should be at last
{
}
Saber ShaikhPosted Feb 4, 2015, 6:56 AM
VulpesPosted Feb 4, 2015, 6:52 AM
If the code in the 'try' block can throw several different types of exception, then you can have multiple 'catch' blocks each of which deals with a different type of exception.