locked
Developing With Exceptions, To Break Or Not To Break? RRS feed

  • Question

  • Should I be breaking on exceptions while debugging?

    I've inherited an asp application that is throwing a large number of exceptions (on start up/page load) and just swallowing them with an empty catch block.

    it was always my understanding that any exception that is thrown while running an application is BAD! (yes/no)???

    I know best practices say "never swallow an exception with an empty catch block" so my general feeling here is that the application isn't well written.

    Should I just turn off breaking on exceptions in the debugger and ignore them or should I try and fix these exceptions (re work the code so no exception is thrown?

    What is the best practice here?


    chuckdawit



    • Edited by witdaj Friday, March 30, 2012 5:38 PM
    Friday, March 30, 2012 5:37 PM

Answers

  • Tr fix the empty catch block with retry and logging logic or if the user needs to be notified, repack the exceptions with some user-friendly exception.


    The following is signature, not part of post
    Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.
    Visual C++ MVP


    • Edited by Sheng Jiang 蒋晟 Friday, March 30, 2012 10:15 PM
    • Marked as answer by witdaj Thursday, April 19, 2012 6:20 PM
    Friday, March 30, 2012 10:15 PM

All replies

  • Tr fix the empty catch block with retry and logging logic or if the user needs to be notified, repack the exceptions with some user-friendly exception.


    The following is signature, not part of post
    Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.
    Visual C++ MVP


    • Edited by Sheng Jiang 蒋晟 Friday, March 30, 2012 10:15 PM
    • Marked as answer by witdaj Thursday, April 19, 2012 6:20 PM
    Friday, March 30, 2012 10:15 PM
  • It is best to try and resolve the exceptions and not "eat" the errors. You should consider creating some tests before you start refactoring the code to remove the exceptions. This way you can be confident your changes are not breaking existing functionality.

    Paul Delcogliano

    Friday, March 30, 2012 10:35 PM