-
Notifications
You must be signed in to change notification settings - Fork 791
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add .finally
#315
Comments
Javascript already has a finally. Just use it co(function * () {
try {
// try to work
} catch (e) {
// handle your errors
} finally {
// cleanup
}
}) |
Yes, all of us, know this, but the intend to use a module like co is invert this control... The same logic can be applied from catch too.. "javascript alreay has a catch" then why co need have one ? example:
|
Co doesn't add a catch either, because you don't need one. You use the js keywords const obj = {
insertInDb: function*(attrs){
//without try ...
}
}
co(function * () {
try {
yield obj.insertInDb(attrs)
} catch e() {
...
} finally{
..close connections etc
}
}) |
The
Would have to be on the |
You can use .then() after .catch() it will work as .finally() https://stackoverflow.com/a/35999141/1753349 |
Bluebird already provides the
.finally
logic which in some situations makes the code cleaner. it will be good ifco
can have it too.The text was updated successfully, but these errors were encountered: