Created
April 11, 2016 15:25
-
-
Save cbaclig/7fefa4ea8b445e9ad95abb34c3baef3c to your computer and use it in GitHub Desktop.
Example of error not being handled in last function of Step
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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