Coding Practice: Exception Handling

Coding Practice: When should I ignore exceptions?
There is never an acceptable time to catch an exception and ignore it.  If you catch an exception, at the very least you should log the exception.  If an exception gets thrown frequently, then this is an indication that something is fundamentally wrong with your code and you should fix it at the root.

“The worst thing you can do is catch (Exception) and put an empty code block on it. Never do this.”
–            Daniel Turini

You should never have code written in this way:

   int val = GenericLibrary.ConvertToInt(userInput);
   return val;
catch (Exception)
   //this always throws an exception and I don’t know why


About Chris VanHoose

Principal Software Architect at CT Lien Solutions
This entry was posted in Software Architecture and tagged , . Bookmark the permalink.

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.