ServiceStack/ServiceStack — pull request #743 by CaspianCanuck (2013-06-26 16:19:03+00:00)
Title: Update Container.cs

I have just spent an hour trying to figure out what was wrong with my code because Funq's Resolve was throwing an "Object reference not set to an instance of an object" exception for a registration that I knew for sure was correct. After painstaking debugging it turned out that the problem was in the lambda for one of the autowired dependencies buried several levels down (i.e. it was a dependency of a dependency of a dependency...etc.).

In order to make this sort of problems easier to diagnose right away, I have added a simple try-catch error handling to all ResolveImpl methods. Now the origin of the exception can be clearly traced by examining the hierarchy of inner exceptions.