'Throw inside Catch block, StackTrace information lost
The last paragraph of the remark section of VB Throw Statement doc says:
The Throw statement resets the call stack for the expression exception. If expression is not provided, the call stack is left unchanged. You can access the call stack for the exception through the StackTrace property.
So I expect when an exception happens in my following code, I can see the complete stacktrace information in VS debugging view, since I haven't put ex after Throw.
For Each item in someEF6LinqQuery
Try
'do many things with the item
Catch ex As Exception
ex.Data("AKeyForDebugging") = item.KeyColumn
Throw
End Try
Next
But it turns out the first line number I got in the stacktrace is just that of the Throw line.
I have to comment out the Try statement and the Catch block so that I can see the line number where , say the NullReferenceException, was actually thrown.
I want to know what I have misunderstood.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
