问题
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