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

徘徊边缘 提交于 2020-01-03 17:16:11

问题


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.


回答1:


If you go to the Debug menu and choose Exceptions... (or press Ctrl+Alt+E), you'll get a 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.




回答2:


Try Debug menu > Exceptions > Add




回答3:


Yes, just use the __debugbreak function



来源:https://stackoverflow.com/questions/10342272/can-i-make-visual-studio-break-on-a-user-defined-c-exception

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!