Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Only break for certain exception types

I know Exception Handling is a very important thing and we are doing it in all our projects. The main reason is to log errors that occur at the customers. This works fine and is not problem at all.

But while I am still coding and running the application with Visual Studio I don't want any exception handling at all. I want the debugger stop right at the line the application crashed and not in some error logger I wrote. And I don't want to forward exceptions with throw!

But I am still looking for an easy way to do that. I could write countless #if Debug or #if Release statements all around the try/catch but that is not what I want to do. Is there any other way to deal with this problem?

like image 672
TalkingCode Avatar asked Mar 02 '10 16:03

TalkingCode


People also ask

How do I break all exceptions in Visual Studio?

Tell the debugger to break when an exception is thrownIn the Exception Settings window (Debug > Windows > Exception Settings), expand the node for a category of exceptions, such as Common Language Runtime Exceptions. Then select the check box for a specific exception within that category, such as System.

How do I make Visual Studio not stop on exception?

Note: you can uncheck Break when this exception type is thrown directly in the exception handler and continue debugging (press F5 ). Visual Studio will add this exception type to the Exception settings and will remember that it shouldn't break on this exception again.


3 Answers

(1) Open Visual Studio with your project
(2) Debug Menu, Exceptions
(3) For the exception types you care about tick the Thrown box.

This will make it so that whenever an exception of the types chosen is thrown you will automatically break into it. When you want to go back to regular debugging go back to that same Exceptions window and click "Reset All" and you'll go back to the default settings.

like image 185
Jason Punyon Avatar answered Sep 27 '22 16:09

Jason Punyon


You can configure the Visual Studio debugger to break when the exception is thrown. See the menu Debug -> Exceptions.

For additional information:

How to: Break When an Exception is Thrown

like image 34
João Angelo Avatar answered Sep 27 '22 16:09

João Angelo


in visualstudio Menu Debug->Exception Check all under the column "Thrown". By default, All items will be check for column "User Unhandled"

This way, debugger will break whenever the exception is thrown.

Note: this will not be part of project property

like image 45
SysAdmin Avatar answered Sep 27 '22 16:09

SysAdmin