Closed elunic closed 5 years ago
I think this is related to #12 in that @chanlito wants to be able to catch errors promise-style.
Looks good to me!
@talyssonoc: I think if you merge and ship this, you can close #12 as well and have no more open issues on the repo.
P.S. @elunic thank you for maintaining 100% code coverage! š
No problem. Nobody wants their PR to break a repo!
I really like this feature and would appreciate if it is merged very soon. š
@talyssonoc could you merge it soon? (or: @jhoscar1 or @blove)
I've reached out to @talyssonoc on Twitter to see if he would consider giving me contributing and publishing rights.
@elunic @whefter @maxstrauch This has been released as v2.0.0 on npm ā the major increment is due to the Awilix v3 -> v4 update.
Thanks for the PR!
Thanks for merging in š š
We've been using
bottlejs
extensively but are looking to switch to Awilix to leverage its advanced capabilities when it comes to scoped and transient service instances as well asawilix-express
for the decorator syntax.We've written our own adapter for
express
andbottlejs
(bottlejs-express
). One thing we included that is immensely useful is handling of errors in routes that areasync functions
. When an async method (route) throws an error, that rejected promise is not handled byexpress
orawilix-express
.As a result, each method would have to include a
try/catch
block, which is easy to forget, resulting in swallowed errors, or greatly reduces readability of the code.The included PR introduces a wrapper for handling rejected promises coming from async routes. I have included as many tests as I thought were relevant. We're really looking forward to using this module, but it's not an option without this error handling.
Please let me know if there are any adjustments you think should still be made. Thanks!