Skip to content

Instantly share code, notes, and snippets.

@oxbowlakes
Last active April 20, 2018 14:47
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 oxbowlakes/05f2c1f10378bdc79ef35c3e08a39016 to your computer and use it in GitHub Desktop.
Save oxbowlakes/05f2c1f10378bdc79ef35c3e08a39016 to your computer and use it in GitHub Desktop.
//In scalaz 8 IO
IO.fail(new Error("1"))
.ensuring(IO.fail(new Error("2")))
.ensuring(IO.fail(new Error("3")))
.catchAll[E](e4 => IO.sync(println(e4.toString)))
//is (I think) equivalent to this?
try {
try {
try {
throw new Error("1")
} finally {
throw new Error("2")
}
}
finally {
throw new Error("3")
}
}
catch {
case e4: Throwable => println(e4.toString)
}
//What do they print?
// the scalaz version will print `Error(1)` - finalizer errors are swallowed
// the try/finally version will print `Error(3)` - original exceptions are swallowed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment