mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-07 14:05:52 +01:00
Apply scala.util.control.Exception to exception handling.
This commit is contained in:
@@ -3,7 +3,7 @@ package util
|
|||||||
import org.eclipse.jgit.api.Git
|
import org.eclipse.jgit.api.Git
|
||||||
import org.eclipse.jgit.revwalk.RevWalk
|
import org.eclipse.jgit.revwalk.RevWalk
|
||||||
import org.eclipse.jgit.treewalk.TreeWalk
|
import org.eclipse.jgit.treewalk.TreeWalk
|
||||||
import org.eclipse.jgit.transport.RefSpec
|
import scala.util.control.Exception._
|
||||||
import scala.language.reflectiveCalls
|
import scala.language.reflectiveCalls
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -16,10 +16,8 @@ object ControlUtil {
|
|||||||
def using[A <% { def close(): Unit }, B](resource: A)(f: A => B): B =
|
def using[A <% { def close(): Unit }, B](resource: A)(f: A => B): B =
|
||||||
try f(resource) finally {
|
try f(resource) finally {
|
||||||
if(resource != null){
|
if(resource != null){
|
||||||
try {
|
allCatch {
|
||||||
resource.close()
|
resource.close()
|
||||||
} catch {
|
|
||||||
case e: Throwable => // ignore
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package util
|
package util
|
||||||
|
|
||||||
import scala.util.matching.Regex
|
import scala.util.matching.Regex
|
||||||
|
import scala.util.control.Exception._
|
||||||
import javax.servlet.http.{HttpSession, HttpServletRequest}
|
import javax.servlet.http.{HttpSession, HttpServletRequest}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -42,10 +43,8 @@ object Implicits {
|
|||||||
sb.toString
|
sb.toString
|
||||||
}
|
}
|
||||||
|
|
||||||
def toIntOpt: Option[Int] = try {
|
def toIntOpt: Option[Int] = catching(classOf[NumberFormatException]) opt {
|
||||||
Option(Integer.parseInt(value))
|
Integer.parseInt(value)
|
||||||
} catch {
|
|
||||||
case e: NumberFormatException => None
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,12 +13,7 @@ object Keys {
|
|||||||
/**
|
/**
|
||||||
* Session key for the logged in account information.
|
* Session key for the logged in account information.
|
||||||
*/
|
*/
|
||||||
val LoginAccount = "LOGIN_ACCOUNT"
|
val LoginAccount = "loginAccount"
|
||||||
|
|
||||||
/**
|
|
||||||
* Session key for the redirect URL.
|
|
||||||
*/
|
|
||||||
val Redirect = "REDIRECT"
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Session key for the issue search condition in dashboard.
|
* Session key for the issue search condition in dashboard.
|
||||||
@@ -47,6 +42,20 @@ object Keys {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
object Flash {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Flash key for the redirect URL.
|
||||||
|
*/
|
||||||
|
val Redirect = "redirect"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Flash key for the information message.
|
||||||
|
*/
|
||||||
|
val Info = "info"
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Define request keys.
|
* Define request keys.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user