Created
January 7, 2013 02:08
-
-
Save johnynek/4471756 to your computer and use it in GitHub Desktop.
Wrapping Throwable in either.
This file contains hidden or 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
def attempt[T](t: => T): Either[Throwable, T] = { | |
try { | |
Right(t) | |
} | |
catch { | |
case e: Throwable => Left(e) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment