|
| 1 | +--- |
| 2 | +title: "Inspect an exception - Visual Studio | Microsoft Docs" |
| 3 | +ms.date: "1/18/2020" |
| 4 | +ms.topic: "conceptual" |
| 5 | +dev_langs: |
| 6 | + - "CSharp" |
| 7 | + - "VB" |
| 8 | + - "FSharp" |
| 9 | + - "C++" |
| 10 | + - "JavaScript" |
| 11 | +helpviewer_keywords: |
| 12 | + - "exception helper, debugger, exception" |
| 13 | + - "debugging [Visual Studio], exception helper, Examine an exception" |
| 14 | +author: "mikejo5000" |
| 15 | +ms.author: "mikejo" |
| 16 | +manager: jillfra |
| 17 | +ms.workload: |
| 18 | + - "multiple" |
| 19 | +--- |
| 20 | +# Inspect an exception using the Exception Helper |
| 21 | + |
| 22 | +Dealing with exceptions is a common problem, no matter your technology or level of expertise. It can be a frustrating experience figuring out why exceptions are causing problems in your code. When you're debugging an exception in Visual Studio, we want to lessen that frustration by providing you with relevant exception information to help you debug your issue faster. |
| 23 | + |
| 24 | + |
| 25 | + |
| 26 | +## Pause on the exception |
| 27 | +When the debugger breaks on an exception, an exception error icon appears to the right of that line of code. A non-modal Exception helper will appear near the exception icon. |
| 28 | + |
| 29 | + |
| 30 | + |
| 31 | +## Inspect exception info |
| 32 | +You can instantly read the exception type and exception message in the Exception Helper, and whether the exception was thrown or unhandled. You can inspect and view properties of the Exception object by clicking the **View Details** link. |
| 33 | + |
| 34 | +## Analyze null references |
| 35 | +Starting in Visual Studio 2017, for both .Net and C/C++ code, when you hit a `NullReferenceException` or an `AccessViolation`, you see null analysis information in the Exception Helper. The analysis is displayed as text beneath the exception message. In the illustration below, the information is shown as "**s** was null.". |
| 36 | + |
| 37 | + |
| 38 | + |
| 39 | + |
| 40 | +> [!NOTE] |
| 41 | +> Null reference analysis in managed code requires .NET version 4.6.2. Null analysis is currently not supported for Universal Windows Platform (UWP) and any other .NET Core applications. It is only available while debugging code that does not have any Just-In-Time (JIT) code optimizations. |
| 42 | +
|
| 43 | +## Configure exception settings |
| 44 | +You can configure the debugger to break when an exception of the current type is thrown from the **Exception Settings** section of the Exception Helper. If the debugger is paused at a thrown exception, then you can use the checkbox to disable breaking on that exception type when thrown in the future. If you don't want to break on this particular exception when thrown in this particular module, tick the checkbox by the module name under **Except when thrown from:** in the **Exception Settings** window. |
| 45 | + |
| 46 | +## Inspect inner exceptions |
| 47 | +If the exception has any inner exceptions ([InnerException](https://docs.microsoft.com/dotnet/api/system.exception.innerexception), you can view them in the Exception Helper. If there are multiple exceptions present, you can navigate between them using the left and right arrows shown above the call stack. |
| 48 | + |
| 49 | + |
| 50 | + |
| 51 | +## Inspect rethrown exceptions |
| 52 | +In cases where an exception has been `thrown` the Exception Helper shows the call stack from the first time the exception was thrown. If the exception was thrown multiple times, only the call stack from the original exception is shown. |
| 53 | + |
| 54 | + |
| 55 | + |
| 56 | +## Share a debug session with Live Share |
| 57 | +From the Exception Helper, you can start a [Live Share](https://docs.microsoft.com/visualstudio/liveshare/) session using the link **Start Live Share session...**. Anyone who joins the Live Share session can see the Exception Helper along with any other debug information. |
0 commit comments