[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() { override fun close() {
val mainException = closeCachesManager() val mainException = closeCachesManager()
val exceptionToThrow = runCatching {
try {
if (isSuccessful) { if (isSuccessful) {
cleanupStash() cleanupStash()
} else { } else {
revertChanges() revertChanges()
cleanupStash() cleanupStash()
} }
} catch (t: Throwable) { }.exceptionOrNull().run {
mainException?.addSuppressed(t) if (this != null) {
throw mainException ?: t mainException?.addSuppressed(this)
}
mainException ?: this
}
if (exceptionToThrow != null) {
throw exceptionToThrow
} }
} }
} }