FastJarHandler: Add information for exceptions thrown during CD parsing

^KT-52786 Related
This commit is contained in:
Denis.Zharkov
2022-07-12 13:50:59 +02:00
committed by teamcity
parent 6064945e79
commit f7a2889a40
@@ -22,7 +22,11 @@ class FastJarHandler(val fileSystem: FastJarFileSystem, path: String) {
RandomAccessFile(file, "r").use { randomAccessFile ->
val mappedByteBuffer = randomAccessFile.channel.map(FileChannel.MapMode.READ_ONLY, 0, randomAccessFile.length())
try {
entries = mappedByteBuffer.parseCentralDirectory()
entries = try {
mappedByteBuffer.parseCentralDirectory()
} catch (e: Exception) {
throw IllegalStateException("Error while reading '${file.path}': $e", e)
}
cachedManifest =
entries.singleOrNull { StringUtil.equals(MANIFEST_PATH, it.relativePath) }
?.let(mappedByteBuffer::contentsToByteArray)