devtrends/Unity.WebAPI

why no need to catch the IHttpController resolve exception?

Closed this issue · 1 comments

in UnityDependencyScope.cs line 22,
if

if (typeof(IHttpController).IsAssignableFrom(serviceType))
{
        return Container.Resolve(serviceType); // throw exception, how to handle?
 }

The IDependencyResolver help page states that:

Implementers should return null when the service cannot be found.

This was implemented for all cases except controller resolution where allowing Unity to throw an exception seemed more logical. If the controller cannot be instantiated then your application cannot continue so the exception makes sense here.