Can I enable/disable breaking on Exceptions programmatically?

后端 未结 5 998
天涯浪人
天涯浪人 2021-02-08 02:29

I want to be able to break on Exceptions when debugging... like in Visual Studio 2008\'s Menu Debug/Exception Dialog, except my program has many valid exceptions before I get to

5条回答
  •  再見小時候
    2021-02-08 03:11

    This is a bit of too late for you, but this is the biggest reason I often try to teach people to use exceptions conservatively. Only use exceptions when something catastrophic has happened and your ability to reasonably continue is gone.

    When debugging a program I often flip on First Chance Exceptions (Debug -> Exceptions) to debug an application. If there are a lot of exceptions happening it's very difficult to find where something has gone "wrong".

    Also, it leads to some anti-patterns like the infamous "catch throw" and obfuscates the real problems. For more information on that see a blog post I made on the subject.

    In terms of your problem, you can turn on first chance debugging for only a specific type of exception. This should work well unless the other exceptions are of the same type.

提交回复
热议问题