3 ms·
This is how I've been writing Iced Coffeescript for years. I still believe it's a major improvement over the typical promise syntax. And to make the error han
by doublerebel 10y ago
This is how I've been writing Iced Coffeescript for years. I still believe it's a major improvement over the typical promise syntax.
And to make the error handling even cleaner, check out the errify/errorCallback pattern:
http://maxtaco.github.io/programming/2014/09/18/handling-errors-in-iced-coffee-script/ http://maxtaco.github.io/programming/2014/09/18/handling-err...
https://www.npmjs.com/package/errify https://www.npmjs.com/package/errify
https://github.com/nextorigin/express-rendertype/blob/master/src/fancy.coffee https://github.com/nextorigin/express-rendertype/blob/master...
- romanovcode 10y agoHm, looks interesting. I wonder if it would be possible to monkey-patch the defer itself in something like this. So that defer itself is handling it, but only if you do the the monkey-patching per file and not globally. defer = require 'defer-esc' await req.get 'https://x.io', defer err, http, res # if err will call cb err await req.get "https://x.io?hash=#{res.hash}", defer err, http, res # if err will call cb err return cb res