Skip to content

Instantly share code, notes, and snippets.

@rcoh
Created April 18, 2014 23:41
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 rcoh/11068694 to your computer and use it in GitHub Desktop.
Save rcoh/11068694 to your computer and use it in GitHub Desktop.
Why you should never catch throwable.
def inlineme(f: => Int): Int = {
try {
f
inlineme {
return 0
}
} catch {
case ex: Throwable => println(ex); return 1
}
}
def doStuff {
val res = inlineme {
10
}
println("we got: " + res)
}
doStuff
// Prints:
// scala.runtime.NonLocalReturnControl
// we got: 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment