Nesting of Exceptions try catch blocks.

suggest change

One is able to nest one exception / try catch block inside the other.

This way one can manage small blocks of code which are capable of working without disrupting your whole mechanism.

try 
{
		// some code here
    try 
    {
        // some thing which throws an exception. For Eg : divide by 0
    }
    catch (DivideByZeroException dzEx)
    {
        // handle here only this exception
        // throw from here will be passed on to the parent catch block
    }
    finally
    {
        //any thing to do after it is done.
    }
	  // resume from here & proceed as normal; 
}
catch (Exception e)
{
    // handle here
}

Note: Avoid Swallowing Exceptions when throwing to the parent catch block

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents