News for hackers. Stuff that matters.
Re:Async and Await by doublerebel on Friday June 03, 2016 @05:30AM (#11829213)
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-err...

https://www.npmjs.com/package/errify

https://github.com/nextorigin/express-rendertype/blob/master...

Re:Async and Await by romanovcode on Friday June 03, 2016 @06:01AM (#11829304)
Hm, 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