Use try/catch/finally structured exception handling blocks around code to avoid unhandled exceptions. Use finally blocks to execute code that runs whether an exception is trapped; this is useful for releasing resources such as closing files or disposing of objects. A structured exception handling helps you create and maintain programs with robust, comprehensive error handlers. If an exception is not handled properly it might leave your application unstable and un-usable. Also finally blocks guarantees that any resources allocated in the try block of the code will get a chance to be cleaned in the finally block which is executed at the last. Here is how you use the structured exception handling
try{
// code that might throw an exception
}
catch (knownException){
// do exception handling
}
catch{
// generic exception handler, do exception handling
}
finally{
// free any allocated resources
}