avoid NumberFormatException

This commit is contained in:
xuwei-k
2013-10-14 03:26:47 +09:00
parent 3eab4955b9
commit 5a3207ae42
6 changed files with 55 additions and 32 deletions

View File

@@ -41,6 +41,12 @@ object Implicits {
}
sb.toString
}
def toIntOpt: Option[Int] = try {
Option(Integer.parseInt(value))
} catch {
case e: NumberFormatException => None
}
}
implicit class RichRequest(request: HttpServletRequest){
@@ -69,4 +75,4 @@ object Implicits {
}
}
}
}