Another of my interesting phrases (or at least I don't know if someboddy used this phrase). What is silent catch? Silent catch is a term I use for try .. catch block, where the catch does nothing or at least you don't see it to be doing anything. The first example: try { some unsafe code here ... } catch {} Another example: try { some unsafe code here ... } catch (Exception ex) { hide something (for example grid or some other control) ... return; } The second example is as bad as the first. It will be underlined by the Microsoft Visual Studio code editor to warn you that the ex object isn't used anywhere within the body of the catch statement. Today I spent about two hours to investigate why a page doesn't display |
So:
"Try to avoid silent catch statements as they may cost you a lot of efforts to find the problem later (even if you wrote the code on your own)."
2 comments:
Hi, Pavka! I am very glad that you have joined our team! For the post - I am on the same opinion. I will just mention that there is a little difference between
try{}catch(Exception) and try{} catch{}. The second catches all exception including the one from unmanaged code. Keep up blogging! Best regards, Vesko Kolev
Thanks for the valuable post, I didn't know about this "slight" difference in both try .. catch scenarios, but you will agree with me that both of them are causing great pain for a developer, since he / she will need to start troubleshooting the problem from the user interface.
Post a Comment