Skip to content

Instantly share code, notes, and snippets.

@cbaclig
Created April 11, 2016 15:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cbaclig/7fefa4ea8b445e9ad95abb34c3baef3c to your computer and use it in GitHub Desktop.
Save cbaclig/7fefa4ea8b445e9ad95abb34c3baef3c to your computer and use it in GitHub Desktop.
Example of error not being handled in last function of Step
Step = require 'step'
callback = (err) ->
console.log if err
"Handled by callback: #{err.toString()}"
else
"callback called with no error!"
try
Step(->
throw new Error "When using callback as the last step function"
, callback)
Step(->
throw new Error "When calling callback() directly"
callback()
)
catch e
console.log "Handled by try/catch: #{e.toString()}"
finally
console.log "Done!"
# Output:
#
# $ coffee step-error-handling.coffee
# Handled by callback: Error: When using callback as the last step function
# Handled by try/catch: Error: When calling callback() directly
# Done!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment