1

I'm working on a project where a lot of bad code is written.

Today I came across a piece of code that caught and exception and just returned an empty string to "handle" it (very difficult to debug).

I was wondering whether there was any way of knowing that an exception has been thrown and caught in visual studio 2010?

Barry Kaye
  • 7,682
  • 6
  • 42
  • 64
Mead3000
  • 581
  • 2
  • 5
  • 18
  • I think this one has been answered already http://stackoverflow.com/questions/116896/visual-studio-how-to-break-on-handled-exceptions – Mikey Mouse Apr 02 '12 at 12:09

5 Answers5

0

VS menu -> Debug -> Exceptions -> Enable CLR Exceptions (CTRL+ALT+E)

There you can choose from "Thrown" or "user un-handled", obviously you need to break on "Thrown" exceptions

The debugger can break execution of your application immediately when an exception occurs, giving you a chance to debug the exception before a handler is invoked.

More details on MSDN: How to: Break When an Exception is Thrown

Important note - this feature is not available on Visual Studio "Web Developer" edition

sll
  • 61,540
  • 22
  • 104
  • 156
0

Go to the 'debug' menu, select 'exceptions' and check 'Thrown' next to Common Language Runtime Exceptions. When debugging, this will break at any point an exception is thrown when debugging.

Steve Martin
  • 1,632
  • 10
  • 19
0

On the "Debug" menu choose "Exceptions..." and then tick "Thrown" and/or "User-Unhandled" for Common Language Runtime Exceptions.

Barry Kaye
  • 7,682
  • 6
  • 42
  • 64
0

This is not possible.

Visual Studio has settings for stopping either when unhandled exceptions occur or whenever an exception is thrown (or both).

There is no setting for exceptions that have been caught (as this would be a very common case and would overwhelm the display).

Oded
  • 489,969
  • 99
  • 883
  • 1,009
0

The debugger writes a entry to the output window when an exception is thrown. http://msdn.microsoft.com/en-us/library/x85tt0dd.aspx

You can break when an exception is thrown.

You can use ReSharper to detect unused parameters (catch(Exception e))

Ralf de Kleine
  • 11,464
  • 5
  • 45
  • 87