Skip to content

Instantly share code, notes, and snippets.

@xuwei-k
Created May 26, 2011 08:00
Show Gist options
  • Save xuwei-k/992740 to your computer and use it in GitHub Desktop.
Save xuwei-k/992740 to your computer and use it in GitHub Desktop.
InterruptedExceptionも他のものも全部Catchするやつ
scala> import scala.util.control.Exception._
import scala.util.control.Exception._
scala> val superCatcher = catchingPromiscuously(classOf[InterruptedException]).or(allCatch)
superCatcher: util.control.Exception.Catch[Nothing] = Catch()
scala> superCatcher.either{ "hoge" toInt }
res0: Either[Throwable,Int] = Left(java.lang.NumberFormatException: For input string: "hoge")
scala> superCatcher.either{ throw new InterruptedException }
res1: Either[Throwable,Nothing] = Left(java.lang.InterruptedException)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment