Hi all,
Why is catch(Exception) always a bad idea or good idea when we use it in project?
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Andrew FensterRank #983 · 2K reputationPosted Jul 19, 2011, 6:23 AM EDT
When you catch your exceptions, you can write a message to an error log. You can clean up your data, so you don't crash half way through a process. You can display an error message to the user, so he will know whether his update went through before the crash. You can shut down the application in the manner of your choice, instead of just crashing.
If you record your exceptions to an error log, it makes it much easier to know when and why your application is throwing exceptions.
If you're getting paid to write code, you absolutely have to catch your exceptions.
MarcusRank #1,197 · 1.5K reputationPosted Jul 18, 2011, 9:01 PM EDT
Vilas GiteRank #951 · 2.1K reputationPosted Jul 18, 2011, 9:09 PM EDT
Catch exception always good for handling exception and easy to find out exception type or error message. Good programmer always use catch exception in their projects. Its good habit to use it.. so, i recommend you use it in project....
In this regard there are good articles in our community site.. so refer it form "Our recommended articles' .
---------------------------------------------------------------------------------------------------
If this reply helps your post…then check "This is correct answer"
VulpesRank #55 · 29.2K reputationPosted Jul 18, 2011, 11:32 PM EDT
sunakshi saxena47 reputationPosted Jul 19, 2011, 10:04 AM EDT
you can refer below article for better understanding of catch(Exception) is good or bad.
http://heathesh.com/post/2010/02/01/Good-and-bad-exception-(error)-handling.aspx
Please mark as accepted answer if you like it.
Thanks
Sunakshi Saxena