Skip to content

Instantly share code, notes, and snippets.

@johnynek
Created January 7, 2013 02:08
Show Gist options
  • Save johnynek/4471756 to your computer and use it in GitHub Desktop.
Save johnynek/4471756 to your computer and use it in GitHub Desktop.
Wrapping Throwable in either.
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