Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to see exception detail in debugger without assigning variable to exception?

I want to see exception detail in visual studio debugger without assigning variable to exception. Currently I have to write something like this:

try  {     //some code } catch (SecurityException ex) {    //some code or ever no any code  } 

Visual studio throws an error indicating that ex variable is never used, but i need this variable to see exception detail while debugging.

UPDATE: I know how to suppress VS error 'variable is never used', problem is in seeing exception inside watch without this variable.


$exception variable by @VladimirFrolov or exception helper by @MarcGravell is an answer.

like image 805
Danila Polevshchikov Avatar asked Apr 11 '13 07:04

Danila Polevshchikov


People also ask

How can you see variable references while debugging?

When stopped in the debugger hover the mouse cursor over the variable you want to look at. The DataTip will appear showing you the value of that variable. If the variable is an object, you can expand the object by clicking on the arrow to see the elements of that object.

How do I view exceptions in Visual Studio?

With a solution open in Visual Studio, use Debug > Windows > Exception Settings to open the Exception Settings window. Provide handlers that respond to the most important exceptions. If you need to know how to add handlers for exceptions, see Fix bugs by writing better C# code.

How do I view an inner exception?

When you're debugging and you get an exception, always, always, always click on the View Details link to open the View Details dialog. If the message in the dialog isn't expanded, expand it, then scan down to the Inner Exception entry.

How do I find exceptions in Windows?

Click Start and select Control Panel. Double-click Windows Firewall to open the Windows Firewall window. Click the Exceptions tab. Click to check mark the box for the program you want.


1 Answers

You can see your exception in Locals list or use $exception in Watch list:

try {     // some code } catch (SecurityException) { // place breakpoint at this line } 
like image 73
Vladimir Avatar answered Sep 18 '22 11:09

Vladimir