Exception thrown at [0]:

I am investigating a stack trace and I came to this conclusion:

Server stack trace: ... at MyProject.Data.Notifications.NotificationCache.InitialisedCache() in NotificationCache.cs: line 72 at System.Lazy`1.CreateValue() Exception rethrown at [0]: at System.Lazy`1.get_Value() at MyProject.Data.Notifications.NotificationCache.AddItemToCache(NotificationDto dto) in NotificationCache.cs: line 82 bla bla bla 

Can someone explain what Exception rethrown at [0]: means and show a simple script how to replicate it? I tried to play it with try / catch / throw, try / catch ex / throw ex etc., but I couldn’t.

+4
source share
1 answer

Lazy<T>.CreateValue raises Exception.PrepForRemoting() , where "Exception added to bit [0]" is added. This is a bit of a weird design choice for some of the author, but apparently he used it as a way to get a split stack trace that would let you see both the code that caused the exception and the code that caused it, despite the fact that the first is called through the delegate.

+4
source

Source: https://habr.com/ru/post/1380623/


All Articles