Apply scala.util.control.Exception to exception handling.

This commit is contained in:
takezoe
2014-03-01 15:22:58 +09:00
parent 17f581f654
commit 374893a5ae
3 changed files with 20 additions and 14 deletions

View File

@@ -1,6 +1,7 @@
package util
import scala.util.matching.Regex
import scala.util.control.Exception._
import javax.servlet.http.{HttpSession, HttpServletRequest}
/**
@@ -42,10 +43,8 @@ object Implicits {
sb.toString
}
def toIntOpt: Option[Int] = try {
Option(Integer.parseInt(value))
} catch {
case e: NumberFormatException => None
def toIntOpt: Option[Int] = catching(classOf[NumberFormatException]) opt {
Integer.parseInt(value)
}
}