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

@@ -3,7 +3,7 @@ package util
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 @@ object ControlUtil {
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
}
}
}