exception handling - If/Else, Try/Catch For Each Or Try/Catch Over Entire If? -


here's example of code...

private sub btndosomething_click(sender system.object, e system.eventargs) handles btndosomething.click         if true             try              catch ex exception              end try                         else             try              catch ex exception              end try           end if end sub 

are there differences adding try/catch on true , false or wrap entire if within 1 try/catch?

yes, depends on how how want handle code featured in each scope. remember, can have different code in each section, , may want handle same exception type differently based on whether condition met or not.

if want generic exception handling (error logging, etc.), should place inside try catch.


Comments

Popular posts from this blog

node.js - Bad Request - node js ajax post -

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -