From a4a1d350213b83a4f5547ba0bff69ef6ff147065 Mon Sep 17 00:00:00 2001 From: "Aleksei.Cherepanov" Date: Fri, 6 Aug 2021 12:48:52 +0300 Subject: [PATCH] Simplify nested errors Replace incomprehensible IndexOutOfBoundsException with intelligible exception #KT-47753 Fixed --- .../src/org/jetbrains/kotlin/incremental/LookupStorage.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/build-common/src/org/jetbrains/kotlin/incremental/LookupStorage.kt b/build-common/src/org/jetbrains/kotlin/incremental/LookupStorage.kt index a3c4aceb497..bf100df6ea9 100644 --- a/build-common/src/org/jetbrains/kotlin/incremental/LookupStorage.kt +++ b/build-common/src/org/jetbrains/kotlin/incremental/LookupStorage.kt @@ -54,9 +54,12 @@ open class LookupStorage( try { if (countersFile.exists()) { val lines = countersFile.readLines() - size = lines[0].toInt() + size = lines.firstOrNull()?.toIntOrNull() ?: throw IOException("$countersFile exists, but it is empty. " + + "Counters file is corrupted") oldSize = size } + } catch (e: IOException) { + throw e } catch (e: Exception) { throw IOException("Could not read $countersFile", e) }