Reported file name when an error occurs while opening a corrupt zip file in Locate

This commit is contained in:
James Roper 2012-08-31 11:01:39 +02:00 committed by Mark Harrah
parent ed902ea565
commit 5e2fc5f005
1 changed files with 5 additions and 2 deletions

View File

@ -5,7 +5,7 @@ package sbt
package inc
import java.io.File
import java.util.zip.ZipFile
import java.util.zip.{ZipException, ZipFile}
import Function.const
object Locate
@ -58,7 +58,10 @@ object Locate
def jarDefinesClass(entry: File): String => Boolean =
{
import collection.JavaConversions._
val jar = new ZipFile(entry, ZipFile.OPEN_READ)
val jar = try { new ZipFile(entry, ZipFile.OPEN_READ) } catch {
// ZipException doesn't include the file name :(
case e: ZipException => throw new RuntimeException("Error opening zip file: " + entry.getName, e)
}
val entries = try { jar.entries.map(e => toClassName(e.getName)).toSet } finally { jar.close() }
entries.contains _
}