Can I make Visual Studio break on a user-defined C

2019-06-24 10:44发布

I have an application that throws many (handled) exceptions. There is one type of exception in particular that I would like to break on.

Is it possible to make the debugger break on a specific user-defined exception? I don't see why this wouldn't be possible, since it does know the type of the exception that was thrown.

I can work around this by setting a breakpoint in the exception's constructor, but it would be nice to know how to do it the 'correct' way.

3条回答
爱情/是我丢掉的垃圾
2楼-- · 2019-06-24 11:15

Try Debug menu > Exceptions > Add

查看更多
Viruses.
3楼-- · 2019-06-24 11:26

Yes, just use the __debugbreak function

查看更多
Bombasti
4楼-- · 2019-06-24 11:40

If you go to the Debug menu and choose Exceptions... (or press Ctrl+Alt+E), you'll get a dialog:

exceptions dialog

You'll need to click the Add... button, enter your custom type name, and make sure that the checkbox by your new exception type is selected.

查看更多
登录 后发表回答