Last active
April 20, 2018 14:47
-
-
Save oxbowlakes/05f2c1f10378bdc79ef35c3e08a39016 to your computer and use it in GitHub Desktop.
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
//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