diff --git a/src/main/scala/util/ControlUtil.scala b/src/main/scala/util/ControlUtil.scala index 02d7fd1..af8db88 100644 --- a/src/main/scala/util/ControlUtil.scala +++ b/src/main/scala/util/ControlUtil.scala @@ -3,7 +3,7 @@ import org.eclipse.jgit.api.Git import org.eclipse.jgit.revwalk.RevWalk import org.eclipse.jgit.treewalk.TreeWalk -import org.eclipse.jgit.transport.RefSpec +import scala.util.control.Exception._ import scala.language.reflectiveCalls /** @@ -16,10 +16,8 @@ def using[A <% { def close(): Unit }, B](resource: A)(f: A => B): B = try f(resource) finally { if(resource != null){ - try { + allCatch { resource.close() - } catch { - case e: Throwable => // ignore } } } diff --git a/src/main/scala/util/Implicits.scala b/src/main/scala/util/Implicits.scala index a9e648c..77c095e 100644 --- a/src/main/scala/util/Implicits.scala +++ b/src/main/scala/util/Implicits.scala @@ -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 @@ 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) } } diff --git a/src/main/scala/util/Keys.scala b/src/main/scala/util/Keys.scala index 4aabe35..920dfca 100644 --- a/src/main/scala/util/Keys.scala +++ b/src/main/scala/util/Keys.scala @@ -13,12 +13,7 @@ /** * Session key for the logged in account information. */ - val LoginAccount = "LOGIN_ACCOUNT" - - /** - * Session key for the redirect URL. - */ - val Redirect = "REDIRECT" + val LoginAccount = "loginAccount" /** * Session key for the issue search condition in dashboard. @@ -47,6 +42,20 @@ } + object Flash { + + /** + * Flash key for the redirect URL. + */ + val Redirect = "redirect" + + /** + * Flash key for the information message. + */ + val Info = "info" + + } + /** * Define request keys. */