Skip to content

Instantly share code, notes, and snippets.

@michaelbartnett
Created October 13, 2017 03:04
Show Gist options
  • Select an option

  • Save michaelbartnett/ebde61e77ecf358402905a7cac8c00e2 to your computer and use it in GitHub Desktop.

Select an option

Save michaelbartnett/ebde61e77ecf358402905a7cac8c00e2 to your computer and use it in GitHub Desktop.
Looking for tricky interactions between closures and exceptions
let print = console.log
let closure = null
try {
let x = 42
let y = null
closure = (msg) => {
x = x + 1
print(msg, x, y)
}
throw "no good"
y = 99
} catch (error) {
try {
print('caught error: ', error)
closure('in nested try: ')
print(y + 1)
} finally {
closure('in finally: ')
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment