Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exception rethrown at [0]:

I'm investigating a stack trace, and I came accross this output:

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

Could somebody please explain what the Exception rethrown at [0]: means and show some simple scenario how to replicate it? I tried to replicate it via try/catch/throw, try/catch ex/throw ex etc but I could not.

like image 378
xhafan Avatar asked Nov 10 '11 17:11

xhafan


1 Answers

Lazy<T>.CreateValue calls Exception.PrepForRemoting(), which is where the "Exception rethrown at [0]" bit gets added. This is a bit of an odd design choice on the author's part, but presumably he was using it as a way to get the "split" stack trace that would allow you to see both the code that caused the exception and the code that called it, despite the fact that the former is invoked via a delegate.

like image 198
Nicole Calinoiu Avatar answered Sep 23 '22 13:09

Nicole Calinoiu