Reputation: 8547
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. :(
Empty
Event.Marshall.GetExceptionCode/Pointers()
doesn't give me anything useful.Evidently something knows about this exception, because VS can show it to me ... how can I get at that exception?
Upvotes: 1
Views: 380
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