[IC] Fix RecoverableCompilationTransaction wasn't throwing an exception properly

#KT-56052 In Progress
This commit is contained in:
Alexander.Likhachev
2023-01-30 21:18:33 +01:00
committed by Space Team
parent 83ea1ca3cf
commit 8825cf7bf6
@@ -240,17 +240,21 @@ class RecoverableCompilationTransaction(
override fun close() {
val mainException = closeCachesManager()
try {
val exceptionToThrow = runCatching {
if (isSuccessful) {
cleanupStash()
} else {
revertChanges()
cleanupStash()
}
} catch (t: Throwable) {
mainException?.addSuppressed(t)
throw mainException ?: t
}.exceptionOrNull().run {
if (this != null) {
mainException?.addSuppressed(this)
}
mainException ?: this
}
if (exceptionToThrow != null) {
throw exceptionToThrow
}
}
}