Unity将异常包装到ResolutionFailedException.如何避免? [英] Unity wraps exception to the ResolutionFailedException. How to avoid?
问题描述
我想知道,是否有可能问Unity在解决时不要包装任何用户异常"?
真的,为什么Unity将包装包装到ResolutionFailedException?它正在改变建筑服务合同",恕我直言,使用统一对象初始化的事实应该是透明的,这意味着如果客户端从新"运算符等待IOException例如,即使使用Unity创建了对象,也应该将其展开. >
其他IoC容器的行为是否相同?
因为您的构造函数不应包含逻辑.
我知道这不是一个完全令人满意的答案,但是我不知道您可以在Unity中关闭此行为-我也愿意同意这是一个奇怪的设计决定... >
但是,如果您简化构造函数,就不会有问题.
I want to know, is there the possibility to ask Unity "do not wrap any user exceptions at resolve time"?
Really, why Unity do wrappings to ResolutionFailedException? It is changing "construction service contract", IMHO the fact of objects initialization using unity should be transparent, that means if client waiting for example for IOException from "new" operator it should get it unwrapped also even object is created using Unity.
Do other IoC containers behave the same?
Because your constructors should contain no logic.
I know that's not a completely satisfying answer, but I'm not aware that you can switch off this behavior in Unity - I also do agree that it's a strange design decision...
However, if you keep your constructors simple, you will not have that problem.
这篇关于Unity将异常包装到ResolutionFailedException.如何避免?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!