Brondahl
Brondahl

Reputation: 8547

Access Visual Studio's $exception variable

I have a situation where an onClose event Handler is running due to an exception thrown.

If I force it to happen with the VS debugger attached, then I can see in VS 'Locals' a $exception local variable, which has (somewhat) interesting information on it.

But I can't figure out how to get at that exception within the code, so that I can log it. :(

Evidently something knows about this exception, because VS can show it to me ... how can I get at that exception?

Upvotes: 1

Views: 380

Answers (1)

Flydog57
Flydog57

Reputation: 7111

The capability you really want doesn't exist. VS magically grabs the current exception and puts it in the $exception pseudo variable in order to make your debugging experience better.

The only place you have access (in your code) to it in in a catch block. If you want to capture it, you need to do it there. There are a bunch more pseudo-variables the VS debugger makes available to you: https://learn.microsoft.com/en-us/visualstudio/debugger/pseudovariables?view=vs-2019

Upvotes: 2

Related Questions