Throwing factories and resolve dependencies block#32
Conversation
There was a problem hiding this comment.
Not sure if the outer throws should be throws or rethrows?
There was a problem hiding this comment.
Here rethrows will not compile cause this method throws error itself.
|
Just make sure you double-check every time you use |
|
Note: once you merge that, make sure to rebase #13 before merging it, as I'm wondering if this change might have impacts on the playground / example code you added there too, like changing calls using |
|
Looks like |
|
👌 |
|
Good catch, these changes actually broke #13 😞 will try to figure out the fix |
|
Fixed the issue, it is safe to merge this now 🎉 |
Throwing factories and resolve dependencies block
With that PR we no more need to call
container.resolve()withtry!inside a factory orresolveDependenciesblock. Also convenient to use throwing constructors or any other throwing methods inside those blocks. Error will be catched by container, printed in console and then will be re-thrown.Note: There is no way (at least for now) I can think of to be able to distinguish between throwing and not-throwing factories (thus the latest definition will override previous), except of duplicating all
register/resolvemethods, what I don't like at all cause it will double the number of methods in container. Taking in account that tag is an optional argument and we have support for 6 runtime arguments already (and upcoming multi-injection feature will ad 6 more methods) it will make API too much bloated.