4. Exception Handling #
Created Monday 27 April 2020
Exception_Handling CN Official Notes
- Exception handling increases maintainability as it seperates errors/exception from intermingling with the logic. i.e error handling is done seperately.
- Error handling does not do implicit conversions.
- It’s like a switch case.
- throw is like return.
- We can form a hierarchy of try throw and catch.
- try must contain throw inside, catch must be in the same scope as try.
- catch(…) should be placed last it is like a default case in switch.
- Every object inside the try is destroyed before going to catch, just like normal return in functions.
- We can define our own exceptions by inheriting from the exception class
should be included. - Everything created inside the catch block is destructed before going to the catch block, so we **cannot **access the value made inside the catch.