Skip to content

Instantly share code, notes, and snippets.

@ProTip
Created June 17, 2015 19:06
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 ProTip/2d051e491ed90ba0fbab to your computer and use it in GitHub Desktop.
Save ProTip/2d051e491ed90ba0fbab to your computer and use it in GitHub Desktop.
Promise = require "bluebird"
async = Promise.coroutine
AsyncError = async ->
throw new Error "AThrower exceptinon."
yield return
NestedAsyncError = async ->
yield do async ->
throw new Error "NestedAsync exception"
NestedPromiseThrower = async ->
yield do ->
new Promise (res, rej) ->
throw new Error "NestedPromise exception."
PromiseThrower = ->
new Promise (res, rej) ->
throw new Error "Promise error."
TryIt = async ->
try
#yield AsyncThrower()
#yield NestedAsyncThrower()
#yield NestedPromiseThrower()
yield PromiseThrower()
catch e
console.log "Caught something! #{e}"
yield return
TryIt()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment