Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can you set VS2008 to break on an error inside a try-catch statement

One of the things I loved about VB6 is that you had the ability to tell the development environment to break on all errors regardless of what error handling you had set up. Is it possible to do the same thing in VS2008 so that the debugger will stop on any error even if it happens inside a try-catch statement?

The problem is particularly hard when you are processing a file with say 500 records and it is failing on one of them - who knows which one - You don't want to modify the code so that your for counter is initialized outside that for loop - that is sloppy long-term. You just want the debugger to know to stop because of some setting you put somewhere.

like image 812
MonkeyBrother Avatar asked Feb 19 '09 19:02

MonkeyBrother


People also ask

How do I create a break on exception 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.

How do I allow exceptions in Visual Studio?

You can open the exception settings window by navigating from Debug -> Windows -> Exception Settings. With Visual Studio 2017, it has some additional features and which is quite useful. You can now set the condition on the exception in the Exception settings Windows.

What is a try catch?

The try-catch statement consists of a try block followed by one or more catch clauses, which specify handlers for different exceptions. When an exception is thrown, the common language runtime (CLR) looks for the catch statement that handles this exception.


2 Answers

Yes, go to "Debug" menu, select "Exceptions...", check "Thrown" for "Common Language Runtime Exceptions"

like image 167
mmx Avatar answered Oct 12 '22 23:10

mmx


Sure, press Ctrl-Alt-E to bring up the exceptions window and tick the Thrown checkbox on Common Language Runtime Exceptions

That will stop the execution, open the source code where the exception was thrown, and tell you with a message window what error it is, pointing at the line it was thrown.

like image 43
juan Avatar answered Oct 12 '22 22:10

juan