Can I use uncaughtexceptionhandler to ignore the exception and move forward? If I can, how to write that handler?
for example:
try{
//something
}catch(exception e){
//something
}
//AND WHEN SOME UNCAUGHT EXCEPTION APPEAR, IGNORE EXCEPTION AND MOVE TO NEXT STEP
try{
//something else
}catch(exception e){
//something else
}
thank you for your attention
You can use the
try .. (catch) .. finally
construct to execute code even if an exception was thrown but not handled.if you add a
catch
in there then execution order istry
up to the point where the exception happened, then the first appropriatecatch
block, then thefinally
block.If you want to execute code in the finally block only if there was no exception, set some flag as the last operation of the
try
block.Note: if you don't
catch
an otherwise uncaught exception somewhere your app will still crash after it has exectued the code infinally
.