Skip to content

Instantly share code, notes, and snippets.

@layerssss
Last active December 10, 2015 23:19
Show Gist options
  • Save layerssss/4508752 to your computer and use it in GitHub Desktop.
Save layerssss/4508752 to your computer and use it in GitHub Desktop.
handler error in `iced-coffee-script`
fs = require 'fs'
_z = (errcb, cb)->
return ()->
return errcb.apply null, arguments if arguments[0]
return cb.apply null, arguments
myfunc = (handler) -> # like `app.get '/', (req, res, next)->` in `express`
handler 'dummy1', 'dummy2', 'dummy3', 'dummy4', (err, data)->
return console.error err.stack if err
console.log data if data
myfunc (param1, param2, param3, param4, next)->
await fs.readFile param1, 'utf8', _z next, defer err, data
console.log "Data: #{data}"
await fs.readFile param2, 'utf8', _z next, defer err, data
console.log "Data: #{data}"
await fs.readFile param3, 'utf8', _z next, defer err, data
console.log "Data: #{data}"
await fs.readFile param4, 'utf8', _z next, defer err, data
console.log "Data: #{data}"
console.log 'complete'
@layerssss
Copy link
Author

@turingou @coolzilj 这种异常处理怎么样?

@layerssss
Copy link
Author

@xinyu198736

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment